Midi Metronome PIC16C54(C) problem

Started by lars-musik, November 03, 2014, 03:55:15 PM

Previous topic - Next topic

lars-musik

Hi there,

Somehow I am stuck with this little circuit. It is an optical metronome to visualise a midi clock. The original article and schematic can be found here: http://www.maxmidi.com/diy/metro/.
I redraw the schematic in diptrace and did an ugly layout for it (hopefully fitting a 1590A), fully expecting it to work nonetheless.





You might already guess that it does not. Maybe a pair of sharp eyes or even a single sharp mind spots an error in my copied schematic or the layout.

Unfortunately I am still clueless about microcontrollers so I just flushed the HEX code delivered on above cited page into a PIC16C54C. My local store didn't stock the called for 16C54 without the "C" but I thought that the other one might be close enough. Now I found a document about migrating a 16C54 code to a 16C54C (http://ww1.microchip.com/downloads/en/DeviceDoc/40233b.pdf) processor. There a some changes that sound crucial to the uneducated ear (eg. "Programming algorithm change, PIC16C54C uses a new programming algorithm").

I measured the only voltage mentioned in the original article (5V across Pin 5 and 14 of the µC) and that is fine.

Any suggestions?  

Thanks in advance, Lars

PS: The overall goal is to equip all our band members with one of those and placing one of these midihubs (https://www.tindie.com/products/hotchk155/midihub-6-way-midi-thru-and-metronome-module/) at the feet of our most reliable stomper. The midi clock should subsequently clock our sequencers and arpeggiators whilst also clocking all musicians to relieve our drummer's ears from the click. Wouldn't it be nice?

PPS: Jumpering S2 and placing an external stomp switch for S1 should make the thingi 3/4 and 4/4 stomp-switchable. I would really like that (much more than the actual 3/4 beat).

lars-musik

I tried a (no, two) PIC16C54 XTI/P today but still no luck.

lars-musik

#2
Maybe it'll help to post the diptrace files I used.
Here is a zip file containing the schematic, the pcb layout the assembler (?) code and the .hex (source code and assembled hex file from the original website). http://www.tekfu.de/musik/metro.zip

Maybe somebody out there has pity on me and takes a look what's wrong there.
Thanks!

slacker

#3
Is your layout shown viewed from the component side? If it is then it looks correct otherwise it's reversed which would explain why it doesn't work.

Do you have an oscilloscope or know someone who has one? This would be useful to see if the board is receiving a midi signal and if the crystal is working.

lars-musik

Thanks for your suggestions. Yes, the layout is shown from the component side. I do have one of these cheap pocket oscilloscopes, good enough for audio applications but limited to 1 MHz. I won't be able to monitor the crystal. But I will try to trace the midi clock signal (although I have no idea what to suspect or where to look for it).


slacker

To see if there is any midi signal getting to it you can probe pin 5 of the MIDI connector, you should get a square wave pattern of about 5 volts, the pattern will change depending on what MIDI commands are being sent. You should get the same signal on pin 17 of the PIC.
You could also probe pins 2 and 18 of the PIC to see if there is any signal there, just in case the problem is something to do with the LED.

lars-musik

Thanks, Ian. That will narrow my search down.
Simultaneously I am going to pursue my usual crude debugging method for circuits with a low part count: I'll build a second one. Unfortunately I don't have another crystal, so it'll be some days.  I already designed a new, slightly more elegant layout.


lars-musik

I am still at loss here.

After doing some research about PIC and the procedure of flashing them, I discovered truths I haven't been aware of previously.

The source code starts with some terms I came across before: "device   pic16c54,xt_osc,wdt_on,protect_off". 

- The "xt_osc" hints towards the setting the configuration words to FOSC1=0 and FOSC0=1, because the XT mode is the one with the 4 MHz crystal from the schematic.
- Second, "wdt_on" tells me to activate the "watchdog timer" by switching on the WDTE-bit in my programmer's software.
- Lastly I switched of all CP (copy protections) bits.

Unfortunately that didn't make my circuit blink either (by the way, I checked with my sequencer and the drum machine: both DO send MIDI clock signals).

Then, because I already burnt all my ordered PIC16C54, I tried to make use of the free MPLAB software to learn something more about PICs (and maybe even be able to migrate the code to some re-writable PICs like the PIC16F54). I got a message that makes me wonder if the hex-file might be faulty in some way. It says "Metro.hex contains code that is located at addresses that do not exist on the PIC16C54."

Could this be the cause of my troubles? Is somebody out there willing to look into the code (and might even be able to perform the migration to a PIC16F54?)

Thanks in advance.


PS: I got a slightly distorted square wave on pin 5 (and 17), nothing on pins 2 or 18.

Here's the source code:

http://www.maxmidi.com/diy/metro/metro.txt

slacker

Quote from: lars-musik on November 15, 2014, 06:05:23 PM
The source code starts with some terms I came across before: "device   pic16c54,xt_osc,wdt_on,protect_off". 

What programmer are you using? You don't normally have to set these in the programming software, the hex file should already contain the correct configuration.

I tried looking at the source code in MPLABX but it has all sorts of errors, I don't know if this is because it is written for a different assembler or if it is because it is very old not compatible with the current assembler. It might be easier to rewrite it from scratch for a modern PIC than try and make that code work, I'll have a go if you like, it doesn't look too complicated. I can't promise anything though.

lars-musik

Hi Ian, that would be great! Re-writing for a modern PIC that is.

If I can be of any assistance (obviously I cannot do the programming but - I don't know - do some pcb layout work) I' d gladly help.

I am using (ordered in China especially for that project) a MiniPro TL866CS programmer, but I also have PIC-KIT3 (not compatible with the PIC16C54) derivative from Olimex. I wanted to get into µC programming myself some time ago but never found the time.

So, I would be very thankful if you could have a try.

An idea, if you are at it anyway: is there a chance to add an output (maybe change the "flash" output in some way) for a relay or something like it, so that the tap-tempo pedals could be synced to the midi clock, too? That would improve the versatility of this circuit greatly.

All the best, Lars