Convert a program from assembler to Arduino

I've been trying to come up with a circuit and the coding for detecting touches on a fencing scoring machine. Is more difficult than I thought.
So, we browsed the internet and found a design & code that looks to be usable - but its written in assembler for an old processor, a PIC16C57 microcontroller.
(darn thing is still around! http://ww1.microchip.com/downloads/en/DeviceDoc/30453b.pdf)

Figure I'd convert it to run on a minipro, once that was done could pull into my existing design, if it got too big then just feeds its light outputs as serial info to my existing design instead (which is where it gets touch info from an expensive scoring machine now).
I've gone thru and defined all the inputs & outputs & pinmodes & stuff, I can sort of follow the assembler, and put all the 'subroutines' into their own void sections.
Not sure what to do next.
If you could guide me some, I'm sure I can do more on my own. Haven't done any assembly since college coding a Zilog Z80 or something like that in a lab (one lab was making text scroll across 7 segment displays, that was fun) and saving our code on cassette tapes.

Here's what I'm starting from
http://www.sonic.net/~schlae/gplscoremach.html

Here's what I have done so far
http://www.crossroadsfencing.com/Score_touch_source.pdf
rename to .pde, my file association for Arduino is still messed up and I couldn't get windows to recognize .pde's to upload it.

Thanks!
Robert

CrossRoads,

you can work yourself through the assembler code, but in the end you'll waste a lot of time for probably little gain. The most useful thing in that source code are the comments. From what I remember, the tough part about a scoring machine isn't the coding, but to know how one needs to react to the various signals - for all three weapons - including necessary timings. As you've probably found out, it's more than just "contact closed - light lamp". For epee I have a rather good understanding how things should be (although I would have to check the regulations about the timings), but foil and sabre I never cared about much.

To move forward with this project, you should create a requirement and design document where you put down how that thing should behave, including all the timings, lock-out, how to handle bouncing contacts and transitions (bell or floor hit to arm or shoe hit - what timing apply) etc for each weapon. This is the hard part. Once you have that, a solution can be designed and the implementation will be probably rather straight forward. If you post it (or send it to me), we even can help.

Korman

Hi Korman,
Thanks for the offer.

Pages 175-181 (as marked, but pages 189-196 if you want to print them out)
capture all the timing & lockout requirements.

I don't see that the one I found does the yellow light for when an epee is grounded (against floor/opponents bellguard) or for when your foil/sabre is touching your own lame, so that would be new. Foil & Sabre give no indicators when the grounded floor is touched.

I was thinking as I went to bed, after having found the PIC datasheet, that since it uses very few commands (only has 33? I think, not sure how many are actually used), that I could just define more variables for everywhere it called out a register and just do the same commands in arduino code, and let the arduino convert it to the assembler the ATMega needed.

Robert

Why not just emulate the PIC?

Emulate the PIC - I think that's what I was saying, in my cruder hardware way of thinking :slight_smile:

From reading the comments, it looks there are active signals (or maybe just DC but being turned on & off) being sent out to be picked up by other parts of the weapons (or sent out on one fencers side and picked up by the other).
I had been trying to set up multiple level static voltages and then driving a comparator high/low based on what was contacted, and there were more variations than I could account for.

I'm starting to think this will not all fit on a 328 type chip.
I need 1 input for virtualwire.
4 are tied up with SPI.
I need Tx to send out the touch light info to a set of remote lights.
That leaves 14 - and the PIC design needs 7 inputs for picking up the weapon contacts and 7 outputs for driving signals out.
I need a shift-in line for an address select (to know which remote to listen to, figuring to have at least 8 receivers in the same room eventually).
I need a shift-out to load a shift register to turn on lights & buzzer.
And clock/load line for those.

I'm gonna have to go to a bigger ATMega chip I think!
Or go with 2, one to display the time & score & touch that I already have working (15,552 compiled bytes), and a 2nd one doing what the PIC is doing and sending serial info to the 1st saying turn on this light, turn on that light, stop the clock a good touch has been made.