![](/media/cache/profiles/dee5807257e44b600e247c814cc12734.jpg.50x50_q85.jpg)
Program to test the quadrature encoders on the mbed WSE single board computer.
This program uses the mbed WSE project SBC to read from both encoder channels and transmit the program run time and encoder count position to a PC through the virtual com port (USB).
main.cpp@2:d3b8a201002d, 2015-02-10 (annotated)
- Committer:
- jebradshaw
- Date:
- Tue Feb 10 16:16:17 2015 +0000
- Revision:
- 2:d3b8a201002d
- Parent:
- 1:dc6b98039052
Test the encoder ports on the mbed WSE SBC and transmit at 9600 baud to terminal program.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jebradshaw | 0:0e1fba1db6a4 | 1 | // Test program for WSE-PROJ-SBC |
jebradshaw | 0:0e1fba1db6a4 | 2 | // J Bradshaw |
jebradshaw | 0:0e1fba1db6a4 | 3 | // 20140918 |
jebradshaw | 0:0e1fba1db6a4 | 4 | #include "mbed.h" |
jebradshaw | 0:0e1fba1db6a4 | 5 | #include "mbedWSEsbc.h" |
jebradshaw | 0:0e1fba1db6a4 | 6 | |
jebradshaw | 0:0e1fba1db6a4 | 7 | //------------------- MAIN -------------------------------- |
jebradshaw | 0:0e1fba1db6a4 | 8 | int main() |
jebradshaw | 0:0e1fba1db6a4 | 9 | { |
jebradshaw | 1:dc6b98039052 | 10 | long enc1, enc2 = 0; |
jebradshaw | 0:0e1fba1db6a4 | 11 | |
jebradshaw | 0:0e1fba1db6a4 | 12 | mbedWSEsbcInit(9600); //Initialize the mbed WSE Project SBC |
jebradshaw | 0:0e1fba1db6a4 | 13 | |
jebradshaw | 0:0e1fba1db6a4 | 14 | pc.printf("Encoder Test\r\n"); |
jebradshaw | 0:0e1fba1db6a4 | 15 | t.reset(); // zero timer |
jebradshaw | 0:0e1fba1db6a4 | 16 | while(1){ |
jebradshaw | 0:0e1fba1db6a4 | 17 | enc1 = LS7366_read_counter(1); |
jebradshaw | 0:0e1fba1db6a4 | 18 | enc2 = LS7366_read_counter(2); |
jebradshaw | 0:0e1fba1db6a4 | 19 | pc.printf("T=%.2f Enc1=%d Enc2=%d \r", t.read(), enc1, enc2); |
jebradshaw | 0:0e1fba1db6a4 | 20 | led3=!led3; |
jebradshaw | 0:0e1fba1db6a4 | 21 | wait(.02); |
jebradshaw | 0:0e1fba1db6a4 | 22 | }//while(1) |
jebradshaw | 0:0e1fba1db6a4 | 23 | }//main |