mak237 Posted July 9, 2014 Report Share Posted July 9, 2014 For my ongoing project I am trying to interface the Papilio with a Roboteq AX2550 motor controller. The default serial configuration on the arduino and by extension the ZAP IDE is 8 data bits, no parity, and one stop bit. The motor controller can not use this as explained in the excerpt from the manual below: The AX2550 serial communication port is set as follows: 9600 bits/s, 7-bit data, 1 Start bit, 1 Stop bit, Even Parity Communication is done without flow control, meaning that the controller is always ready to receive data and can send data at any time. These settings cannot be changed. You must therefore adapt the communication setting in your PC or microcomputer to match those of the controller. In the Arduino documentation of Serial.begin() it outlines a way to change this by using the format Serial.begin(speed, config) for a command.http://arduino.cc/en/Serial/Begin When I try to enter the appropriate command in the ZAP IDE, Serial.begin(9600, SERIAL_7E1), I get an error stating that 'SERIAL_7E1' undeclared (first use this function). After searching for this error I found a few of references to this problem about a year ago on the arduino forums and people claiming that it worked as of arduino 1.0.4. All of this leads me to the question, is there any easy way to change this with the ZAP IDE? If not, what would I have to do to work around this problem? Is this not possible using the UART in the papilio schematic library? Link to comment Share on other sites More sharing options...
mkarlsson Posted July 10, 2014 Report Share Posted July 10, 2014 Another option is to generate the parity bit yourself, i.e take the 7 bits you want to send, calculate the parity bit and add it, and then send it as 8 bits without parity. See this:http://en.wikipedia.org/wiki/Parity_bithttp://forum.arduino.cc/index.php/topic,44765.0.html Magnus Link to comment Share on other sites More sharing options...
alvieboy Posted July 11, 2014 Report Share Posted July 11, 2014 The current UART implementation only does 8N1. I can provide you a custom implementation for other, if you need. But you can always generate (as Magnus said) the parity bit yourself. Alvie Link to comment Share on other sites More sharing options...
mak237 Posted July 11, 2014 Author Report Share Posted July 11, 2014 Ah, that's good to know. I didn't know if it was something as simple as a bug or configuration problem, or if it was an actual compatability issue. It's How much time would it take for a custom implementation? I don't want to take too much of your time if it can be done more easily some other way. Anyway, it probably would be best having a custom implementation since I'm trying to leave as much of the messy code out of the soft processor as possible to make it easier for people that work with me on the project to read through and understand the code. Mak237 Link to comment Share on other sites More sharing options...
hamster Posted July 12, 2014 Report Share Posted July 12, 2014 Doing a custom UART is a lot of work. Off the top of my head this should be enough C to generate parity for 'a' and set it. It would pay to test it as I haven't even compiled it! char addParity(char a){ unsigned char p; p = a; p ^= (p >> 4); p ^= (p >> 2); p ^= (p >> 1); a |= (p<<7); return a;} and you should then be able to do something like "Serial.write(addParity('h'));", as long as it works as I think it should... Link to comment Share on other sites More sharing options...
mak237 Posted July 12, 2014 Author Report Share Posted July 12, 2014 I'll try that when I get back into the lab on Monday then. Hopefully that's all I need to do to be able to communicate with this motor controller. Thanks for all of the help with this, I really appreciate it. Link to comment Share on other sites More sharing options...
EtchedPixels Posted July 12, 2014 Report Share Posted July 12, 2014 For a byte you can do this and you don't need the later shifts p ^= (p>>4);parity = (0x6996 >> p) & 1; (ie its a fold and a 16 way lookup table) Alan(lookup hack c/o Mathew Hendry) Link to comment Share on other sites More sharing options...
alvieboy Posted July 13, 2014 Report Share Posted July 13, 2014 Doing a custom UART is not that much of hard work. What takes time is to adjust the C++ API to deal with that, and to properly distinguish between all of UART versions. If you wish to do the C++ API adjustments, I can provide you an HDL version to support 8N1, 7E1 and 7O1. You just need to fiddle with two additional configuration bits. Alvie Link to comment Share on other sites More sharing options...
mak237 Posted July 15, 2014 Author Report Share Posted July 15, 2014 I tried the code hamster suggested and it seems to be working. The serial settings on the scope in the lab saw everything I sent to it as having 7 bits with even parity instead of the normal 8 bits with no parity. The only thing left to do is testing it out with the motor controller. Thanks for all the help and suggestions! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.