Hello,
I am pretty new to MCU programming and using the Jrk 21v3 motor controller. I am using a HCS12 microcotrolller from freescale to send/receive messages to/from the Jrk 21v3 via a Serial Control Interface. I have the microcontroller setup to format the messages in UART 8N1; 1 low start bit, data bits 0 to 6, and a high stop bit. I am trying to setup a network with a RoboClaw motor controller and the Jrk. To do this I think I need to use the Pololu protocol.
I have been able to send commands in the compact protocol to get the Jrk to move a linear actuator to a target position, but when I try to use the Pololu protocol I get an error on the Jrk. I am sending 0xAA as the first byte, the device of the Jrk (11 or 0x0B) as the second byte, the set target command (0x40) with the lower 5 bits of the target value in the third byte, and the upper 7 bits of the target value in the fourth byte. I am not getting an error on the Jrk, but it is not moving the linear actuator either.
Here is the code I am using to send the bytes, the (!(SCI0SR1 & 0x80) is a flag that is raised when there is a byte to transmit. The byte it transmitted bitwise so this flag is lowered after the transmission is complete. SCI0DRL is the register that the bytes are written or read from.
[code]void jrkSetTarget (unsigned int s) {
while (SCI0SR1_TDRE)
SCI0DRL = 0xAA; // send to set baud rate and initialize communications
while (SCI0SR1_TDRE)
SCI0DRL = 0x0B; // send the device number
while(SCI0SR1_TDRE) // make sure the last bit is gone
SCI0DRL = 0x40 + (s & 0x1F); // send target command and lower 5 bits of target position
while(SCI0SR1_TDRE) // make sure the last bit is gone
SCI0DRL = ((s & 0xFE0) >> 5); // send the upper 7 bits of the target position
delays (10); // just gives a little time for the linear actuator to get to the target position
}[/code]
I should also mention that I know the bits are being sent because I am watching them on my oscilloscope