I have an apple II, arduino mega, and a modern PC all wired up
the RS232 out of the apple hits a MAX232 and goes into the serial 1 of the MEGA, the MEGA then simply spits out what it reads on serial one back to the PC
the problem is its printing out wrong values, I hit H on the apple and it spits out a value of 200(dec) on the PC Instead of H or 72(dec)
I know its a very old computer (this specific one made in 1986) but I talk to it over serial all the time and its very reliable. if I plug it directly into the computer its fine, plug it into the MAX232 + MEGA and it seems to be working, just with totally wrong ascii values.
the code I am using is not rocket science, just a little blob to verify I got my RX and TX right
byte incomingByte;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
// send data only when you receive data:
if (Serial1.available() > 0)
{
// read the incoming byte:
incomingByte = Serial1.read();
// say what you got:
Serial.println(incomingByte);
}
}
No, because serial sends the low-order (LSB) bits first. If you were only sending 7 bits that would account for it. The eighth bit (the stop bit) is a 1, so that would account for the 1 at the end (the high-order bit).
IIc has a super serial card on its motherboard, and by default starts up a 600,8,N,1 all I do is hit the firmware to change the baudrate to 9600, and again if I hook it directly to a PC, change the baudrate to 9600 I can talk to and from it all day at 9600,8,N,1
Can you try other characters and post what you get after the Arduino?
I have been typing in "hello world" and they all get the 7th bit as 1
Hard to say without hardware debugging. Do you have a scope or logic analyzer? Is the Mega operating at the correct speed? Do you have a way of testing that? If the Mega is running at around 11% slow it would be late sampling each bit, with the result that the 9th bit (8th data bit) could be sampling the stop bit instead.
Just as a test, try tweaking the baud rate on the Mega. Eg. instead of 9600 try 10000. Or more even, like 10600.
The crystal on the Chinese mega (the one thats cost me more time and money than if I bought the real thing at radio shack) is clocking in at 15.285Mhz, so its the bottom of the barrel for a 5% part, but should be close enough
The LA connected direct to the 232 converters tells me that yes the apple is "sending" 0b11001000, confirmed with my TI MAX232 and a modern device P5 232 converter (which is a hex inverter and a zener diode in a nutshell).
I cant measure the real RS232 lines cause my USB LA would explode, but after inversion what happens is the line is high, you send a byte, it twiddles bits and goes back high again after the stop bit, which is where I think its picking up the extra logic high.
Course the question still stands why a PC has zero issues with it, and how do I go about correcting it so I can get to the interesting part of the project
And thanks for your help.
PS: Ill tweak the baud rates tomorrow, but the LA is locking on to the exact baud rate and still getting an extra 1 on the left
that is the entire byte, it looks the same on the LA and it decodes it as value 200
(and yea, if I want to shoot the scope for a article I have to wait till night and shut off most of the lights, for example)
anyway I think we have shown this isnt really an arduino thing, and I have started a line of inquiry on the apple II group, maybe its doing something funny thats being nulled out when plugged into a full rs232 port vs just having RX and TX