I've ported George's Mikro-C code to the Microchip XC8 compiler. Originally I intended to do a direct port with few code changes but I ended up pulling some concepts from the way I'm writing C code for ITMD3, which follows from C++ code I've done elsewhere. As such, it looks a lot different structurally but when you look at the functions most of the code has not actually changed. Here are the differences:
1. Code is more modularized. Modules are
2. The LCD code was ported from my C++ efforts elsewhere and can be used independently. It is not quite finished as scrolling is not implemented, but that's not used in Voodoo.
3. Converted everything to CamelCase, that's just my programming preference.
4. The detector continues to operate while in the menus. Timing is live-changed on every button press so you can see pulse changes on an oscope on the bench or can hear effects on target responses while in the field. Obviously, the screen remains in the menu so the meter is not available.
5. When you exit the menu and re-enter, you re-enter where you left off.
6. There is a new menu item called DISC INVERT which inverts the polarity of the Disc signal. I noted in one of my test coils that the RX coil was phase-inverted so that non-ferrous produced negative bars. This setting allows you to correct for that without having to make major changes to the Disc sample delay.
7. Timers are a little different:
8. I noticed jitter in the Hybrid mode; this is due to the imbalanced number of switch/case evaluations as it alternates between PI & Disc. I found this behavior to be bizarre, it should not be happening as it is interrupt-driven. But adding 2 dummy cases to the Disc side eliminates the jitter.
I've only very loosely tested this code so I post it here with absolutely no guarantee of usability. Please post feedback & bug reports to this thread.
Voodoo.X.2.00.zip Version 2.0
Voodoo.X.2.01.zip Version 2.01
Voodoo.X.2.02.zip Version 2.02
1. Code is more modularized. Modules are
- Voodoo (main)
- VoodooADC
- VoodooDSP
- VoodooEEPROM
- VoodooTiming
- VoodooUI
- LCD
2. The LCD code was ported from my C++ efforts elsewhere and can be used independently. It is not quite finished as scrolling is not implemented, but that's not used in Voodoo.
3. Converted everything to CamelCase, that's just my programming preference.
4. The detector continues to operate while in the menus. Timing is live-changed on every button press so you can see pulse changes on an oscope on the bench or can hear effects on target responses while in the field. Obviously, the screen remains in the menu so the meter is not available.
5. When you exit the menu and re-enter, you re-enter where you left off.
6. There is a new menu item called DISC INVERT which inverts the polarity of the Disc signal. I noted in one of my test coils that the RX coil was phase-inverted so that non-ferrous produced negative bars. This setting allows you to correct for that without having to make major changes to the Disc sample delay.
7. Timers are a little different:
- Tmr1 interrupt runs every half-period.
- At one Tmr1 interrupt, the sequence of Tmr0-based pulses is started, beginning with the TX pulse. The PSSync pin is also set high.
- At the next Tmr1 interrupt the PSSync pin is set low. This can potentially happen in the middle of the Tmr0 pulses but that should not matter.
- This results in a PSSync pulse running at the TX frequency and with a 50% duty cycle.
8. I noticed jitter in the Hybrid mode; this is due to the imbalanced number of switch/case evaluations as it alternates between PI & Disc. I found this behavior to be bizarre, it should not be happening as it is interrupt-driven. But adding 2 dummy cases to the Disc side eliminates the jitter.
I've only very loosely tested this code so I post it here with absolutely no guarantee of usability. Please post feedback & bug reports to this thread.
Voodoo.X.2.00.zip Version 2.0
Voodoo.X.2.01.zip Version 2.01
Voodoo.X.2.02.zip Version 2.02
Comment