|
I have exchausted my search of the forums to find threads specific to this topic and am humbly reaching out for assistance. I am a noob, and finally decided to reach out on the forum.
Configuration: Atom Pro (microcontroller) Robo Claw (motor controller) Two Quadrature Encoders mounted to geared motors Track Drive System Packet Serial (DIP set for packet serial and Robo Claw at address 128; ie SW=3,4, and 5 are on) S1 (Robo Claw) connected to P15 (TX on microcontroller) w/ GND only S2 (Robo Claw) connected to P14 (RX on microcontroller) w/ GND only Right Encoder connected to header (A and B) for encoder 1 on Robo Claw w/ GND and +5V Left Encoder connected to header (A and B) for encoder 2 on Robo Claw w/ GND and +5V
I have successfully used the SEROUT (P15) to control the motors, but am having difficulty integrating HERSOUT/HERSIN to integrate the encoders.
Goal: Control motors and read encoders to terminal and eventually 7-segment display.
Sample Code: Encoder1 Var Long Encoder 2 Var Long Status Var Byte CRC Var Byte
Enablehserial
Pause 250
SetHSerial H38400, H8DATABITS, HNOPARITY, H1STOPBITS
Hserout [128, 20, (148 & 0x7F)]
Main
Serout P15, i38400, [128, 0, 32, (160 & 0x7F)]; motor1 forward Serout P15, i38400, [128, 0, 32, (160 & 0x7F)]; motor2 forward
ReadEncoderM1 Hserout [128, 16] Hserin [Encoder1.byte3, Encoder1.Byte2, Encoder1.Byte1, Encoder1.Byte0, Status, crc] Serout s_out, i38400, [0,”Encoder1: “, SDEC Encoder1, 13, “Status Byte: “, BIN Status]
ReadSpeedM1 Hserout [128, 18] Hserin [Encoder1.byte3, Encoder1.Byte2, Encoder1.Byte1, Encoder1.Byte0, Status, crc] Serout s_out, i38400, [13, 13, “Speed: “, DEC Encoder1, 13, “Direction: “, DEC Status]
ReadEncoderM2 Hserout [128, 17] Hserin [Encoder1.byte3, Encoder1.Byte2, Encoder1.Byte1, Encoder1.Byte0, Status, crc] Serout s_out, i38400, [0,”Encoder1: “, SDEC Encoder1, 13, “Status Byte: “, BIN Status]
ReadSpeedM2 Hserout [128, 19] Hserin [Encoder1.byte3, Encoder1.Byte2, Encoder1.Byte1, Encoder1.Byte0, Status, crc] Serout s_out, i38400, [13, 13, “Speed: “, DEC Encoder1, 13, “Direction: “, DEC Status]
Goto Main
|