I am trying to send a serial command off port c. only i dont know the syntax to send serial commands from the o to my dsmc. Any suggestions?
I haven’t gotten up to doing this myself, but at some point I would also like to get my servo and motor controllers working straight off of the Orangutans. Jim Remington posted some UART code a bit ago for the big Orangutan:
Now, you’re going to want to send out bytes that aren’t necessarily ascii characters, but this is a good starting point, and you may be able to use the “uart_putchar” function as written by setting the “char” to your desired binary or hex values (Jim?).
The good news is that the UART communication protocol is built into the chip, but it is only available on specific pins. I think you will want to connect PD1(txd), which is conveniently brought out to the main header, to the TTL serial input of your DSMC (pin4, if you’re still using the low voltage DSMC). Give them both the same ground reference and you’re all set.
I’m kinda banging my head as I write this because I hate “almost here!” type posts. But…
There was a recent (ok, fairly recent) project posted to avrfreaks.net on doing bit-banged UART code on an ATTiny (which doesn’t have an on-board UART).
I haven’t done this yet, but I was planning to take the bit-bang UART code and make a pin-independent Tx-only UART routine for the Orangutans. The motivation is to have something that can drive the Pololu serial motor and servo controllers (which only need Tx) without tying up the single on-board UART on the ATMega48/168 chips.
The code really isn’t that nasty looking, so if you’re interested you don’t have to wait for me to do it:
The built-in UART does not care what characters (binary values) are sent through it, but it outputs only on port D.1. I think that the UART routines that I posted some time ago should work with the DSMC but I don’t have one to test.
If you want to use port C to control the DSMC, you will have to use “bit-bang” routines and pay special attention to whether the output is inverted. In order to work, the resting state of the output line from the microcontroller has to be +5V. You will also have to take into account the clock speed of the CPU to make sure that the bit rate is correct.
The DSMC has two serial inputs, one of which (SERIN) is supposed to be inverting for direct connection to a PC. Whether this input will work with logic level signals is not clear from the DSMC documentation.