Ticker added
Dependencies: HIDScope MODSERIAL QEI mbed
Fork of Tau_new_ticker_toevoegen by
Diff: main.cpp
- Revision:
- 11:6138cfca0081
- Parent:
- 10:cab7ca2f144a
- Child:
- 12:61f24281f9a3
--- a/main.cpp Thu Nov 02 12:02:01 2017 +0000 +++ b/main.cpp Thu Nov 02 12:17:59 2017 +0000 @@ -36,20 +36,20 @@ // Send angle to HIDScope and pc function void Calculate() { - // Get pulses and calculate angle + // Get number of pulses and calculate angle pulse_count = Encoder.getPulses(); float angle_pp =360/(X * N); float angle = pulse_count*angle_pp; - // Send angle to HIDScope and pc + // Send angle to HIDScope scope.set(0, angle); scope.send(); - pc.printf(" pulse count: %f angle: %f \r \n ", pulse_count, angle); + //Increase counter after measurement counter++; - // Turn motor off and reset encoder to reset pules count - + // Turn motor off and reset encoder if desired rotating time has been reached + // Number of measurements required to reach the desired number of rotations = Rotations / Measurement Frequency = (R/F) if(counter==R/F) { motor1PWM = 0; // motor off @@ -69,7 +69,7 @@ ledb = 1; // blue led off ledr = 0; // red led on = rolling - // Turn motor on for x time and turn it off again + // Turn motor on motor1PWM = 1; // motor on // Reset counter and start measuring @@ -78,7 +78,6 @@ Measure(); } - int main() { // Initialize system @@ -90,7 +89,7 @@ // Dice roll code while(true){ - // Roll dice if button is pressed + // Roll dice if switch2 on K64F is pressed if(button1==0) { Encoder.reset();