;Basicmicro Robo Claw Quadrature Decoder program ;Example will read speed, total ticks and direction ;Switch settins: SW3=ON and SW5=ON. ;Program loops through 4 read commands and prints the ;result to Studio terminal window and 38400 baud. Encoder1 Var Long Encoder2 Var Long Status Var Byte CRC Var Byte Clear ENABLEHSERIAL SetHSerial H19200,H8DATABITS,HNOPARITY,H1STOPBITS Pause 2000 Hserout [128, 20, (148 & 0x7F)]; Resets encoder registers Main Pause 100 ReadEncoderM1 Hserout [128, 16] Hserin [Encoder1.byte3, Encoder1.Byte2, Encoder1.Byte1, Encoder1.Byte0, Status, crc] Serout s_out, i38400, [0,"Encoder1: ", DEC 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 [Encoder2.byte3, Encoder2.Byte2, Encoder2.Byte1, Encoder2.Byte0, Status, crc] Serout s_out, i38400, [13, 13, "Encoder2: ", DEC Encoder2, 13, "Status Byte: ", BIN Status] ReadSpeedM2 Hserout [128, 19] Hserin [Encoder2.byte3, Encoder2.Byte2, Encoder2.Byte1, Encoder2.Byte0, Status, crc] Serout s_out, i38400, [13, 13, "Speed: ", DEC Encoder2, 13, "Direction: ", DEC Status] Goto Main