Converting baud rate
Another FNG
Posts: 3
I'm totally new to the propeller, and am not much of a programmer, so I could use some advice from anyone willing to offer it.
I have a windows program which will only communicate using standard serial baud rates. The device I need to connect it to uses 7812 baud. I've been unsuccessful in figuring out how to override the port speed on my PC once the application has opened the port. I'd bet there's a way to do it with the Win32 API, but like I said...I'm not much of a programmer.
Wanting to learn the propeller anyway, I thought I could run the FullDuplexSerial program at a standard baud rate on one cog for the PC connection (I have that working), and then setup another cog for the slower 7812 baud connection to the device. Where I'm lost is getting the data between the two cogs. This might be basic programming, but being all new to this has me scratching my head now. Any past posts you could suggest I read or any pointers would be GREATLY appreciated.
Thanks!
I have a windows program which will only communicate using standard serial baud rates. The device I need to connect it to uses 7812 baud. I've been unsuccessful in figuring out how to override the port speed on my PC once the application has opened the port. I'd bet there's a way to do it with the Win32 API, but like I said...I'm not much of a programmer.
Wanting to learn the propeller anyway, I thought I could run the FullDuplexSerial program at a standard baud rate on one cog for the PC connection (I have that working), and then setup another cog for the slower 7812 baud connection to the device. Where I'm lost is getting the data between the two cogs. This might be basic programming, but being all new to this has me scratching my head now. Any past posts you could suggest I read or any pointers would be GREATLY appreciated.
Thanks!
Comments
Once you've set up the FullDuplexSerial ports and started them, you do:
where "char" is a long variable and "input" and "output" are instances of the FullDuplexSerial object. Read the comments in the FullDuplexSerial source code for rxcheck and tx.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Searider
You mentioned reading comments in the source, but I haven't found them. In fact I was surprised that there was no documentation at all with FullDuplexSerial in the object exchange. Where do I find the docs?
Searider,
I have no flow controls, so the buffer will have to do it. Is there a way to increase the Rx buffer in the code you see above for the one instance of FullDuplexSerial that needs it, or do I have to increase the Rx buffer in FullDuplexSerial for both directions? I have the available RAM in this case, so this is more of an "efficient design" question.
Post Edited (Another FNG) : 11/9/2008 5:41:33 AM GMT
you don't need to do a cognew(output.start(1, 2, 0, 7812), @stack)
as the startmethod ITSELF does the cognew
start it the same way as the input
output.start(1, 2, 0, 7812)
As long as your input baudrate is lower than the output-baudrate
the buffer cannot fill up
Do have the possability to use a baudrate of 1200 or 2400 on the inputside ?
best regards
Stefan
One more question (yeah, right!)... the device uses a single bi-directional serial wire. Instead of me terminating pins 1 and 2 to the same place on the device will "output.start(1, 1, 0, 7812)" work for a single wire use? Or, will it loop itself back at that pin and never leave the chip?
Note that you will need to set mode bit 2 (and mode bit 3) to allow rx and tx to be on the same pin (and use a pull up resistor if there's not already one). Mode bit 3 will discard one received character for every transmitted character since they will be echoed back (because of the shared line).
You can increase the buffers to any power of two up to 256 by adjusting a couple of bitmasks in the code and one offset in the initialization.