I am hoping that someone with knowledge of PIC programming can help me. I have an old PIC chip that has failed and would like to replace with an Arduino (as I don't have a PIC programmer or software).
The original function of the PIC was to map a potentiometer input to a one byte value and send that value to a MAC running software set to receive and interpret the data. I have attempted to replicate the PIC setup using an Arduino Uno but have only managed once to get the MAC software to respond in any way to the data sent from the Uno.
I do not know exactly how the data is sent from the PIC (I never had a chance to attach a serial monitor to it) so I am just guessing the correct command to use for the Uno.
I have the PIC Basic program (not written by me so I am loth to reproduce it in full here). it contains these commands in the setup:
t96n CON 84
TXout VAR portb.1
byteOUT VAR BYTE
...and this is used to send the mapped data to the MAC:
SEROUT2 TXout,t96n,[byteOUT]
I know that the value 84 corresponds to 9600 baud, no parity, true however I do not know what command to use on the Uno (eg. Serial.write or Serial.print or Serial.println / ,HEX or ,BIN or ,DEC)
Before you ask - I am confident that the physical setup is working fine (I am sending the TX from the UNO to the MAC via the original Serial to USB adapter.
I hope this all makes sense and that someone can help before I pull all my hair out!
Thank you for your reply spycatcher, I feel I've tried all the permutations I can think of. I was concerned that the PIC may send an extra bit so just using Serial.begin(9600) would not suffice - or that I might need to send a carriage return.
I do not know exactly how the data is sent from the PIC
The PIC source code should make that clear. Are you certain that the single line you posted is the only line that sends data to the MAC? It would be most unusual to send a single character.
a MAC running software set to receive and interpret the data
If you have the MAC source code, post the bit that actually receives the data. That should help to understand what is actually expected.
I know that the value 84 corresponds to 9600 baud, no parity, true however I do not know what command to use on the Uno (eg. Serial.write or Serial.print or Serial.println / ,HEX or ,BIN or ,DEC)
You probably want "Serial.write(byteout);"
SEROUT2 looks to be an ME Labs PIC Basic command, with documentation here: http://melabs.com/downloads/PBP_Manual_0609_260.pdf (starting on page 155) It looks like it has BIN/HEX/DEC modifiers, but without a modifier, it just sends the ascii code, which is what Serial.write() does.
Well I feel like a right plum. I'd got it in my head that I couldn't find a legal download of the PBP manual. Thank you westfw.
If you hook up your PIC to the MAC and run a decent terminal program (instead of the application) that can display hexadecimal representations of the data, you might also be able to do some reverse engineering.
Or use an Arduino as man-in-the middle to intercept the data that goes over the 'lines' and output that to e.g. serial monitor. A Mega might be the preferred board for that due to it's abundance of hardware serial ports.
Problem solved!
I just needed to stop trying all the options. Serial.write(byteOut) worked perfectly.
Thank you all for your generous help.