![]() |
Digital I/O Dilemma
We attempted to wire the encoder but have not been able to get any feedback from it using the dashboard.
I split two PWM cables and connected the two power wires to the power wire on the encoder and the same with the ground. I connected the Channel A wire on the encoder to the white wire on one PWM and the Channel B wire to the white wire on the other PWM. http://farm4.static.flickr.com/3315/...121d52.jpg?v=0 I connected one PWM to Digital I/O 3 and the other to Digital I/O 4. I initialized it in the programming like this: Code:
Encoder encoder1;http://farm4.static.flickr.com/3521/...b122de.jpg?v=0 |
Re: Digital I/O Dilemma
Well, I wouldn't be all that surprised by that flickering.
Since your dashboard is updating pretty fast (as fast as you get packets) and the encoder state changes once per 'tick', the value of the encoder ports should change state quickly enough to make the dashboard display a flickering or "both 0 and 1" state on the GPIO port. That's a matter of how slowly your eyes and monitor react. The information you are really after is the number of ticks that have occurred, which is in the FPGA. To get this value, you first have to set the distance per tick, then call Encoder::GetDistance(). The distance per tick defaults to 1.0, so without modification, Encoder::GetDistance returns number of ticks. Your call would look like this: Code:
float dist = encoder1.GetDistance();-Jeff Erickson, FRC 41 |
Re: Digital I/O Dilemma
Quote:
I added this line of code to the teleoperated loop: Code:
dashboard.Printf("Distance: %f\n", encoder1.GetDistance()); |
Re: Digital I/O Dilemma
The initialization code you posted will not work.
Either do: Code:
Encoder encoder1(4, 3, 4, 4, 0);Code:
Encoder *encoder1; |
Re: Digital I/O Dilemma
Be sure to start the encoder or it won't count. I spent an hour remembering this last night. . .
Encoder1->Start(); I test them by getting the value and printing to the console. signed mouseXPosition = Encoder1->Get(); printf("MouseX %d\r\n", mouseXPosition); You can view the console output by right right clicking on the connection to the cRIO and selecting Target Tools / Target Console. This will display all printed data until a reboot. |
| All times are GMT -5. The time now is 09:35. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi