![]() |
Jiggly servo
1 Attachment(s)
We have a two speed transmission that shifts with a servo. We want to press the trigger button to shift between high and low gear. We want the program to Get the Servo angle...decide if it is in high gear (45) or low gear (120)...then shift into the opposing gear.
The problem with the program- program attached below- is... when we pull the trigger button the servo JIGGLES before it decides what gear it sets in. Most of the time it chooses the correct gear but not always. Are we taking the wrong approach? |
Re: Jiggly servo
You want to trigger the change when the button is pressed, but right now you are triggering the change whenever the button is down. This results in it flickering between the two states as fast as the program cycles, and will 'randomly' pick one when you let go.
Try to figure out how you can only trigger when the button wasn't pressed but now is - only once per button push. You are really close, I'm sure you'll get it quickly. As a hint, the "shift register" will remember something one time tick in the past. |
Re: Jiggly servo
It is probably best to think about the problem Eric highlighted for a bit and see if you can solve it yourselves (you'll learn more), but if you get stuck you may find this thread of interest:
http://www.chiefdelphi.com/forums/sh...light=one+shot |
Re: Jiggly servo
Quote:
However, if you really do want to make it work that way, Eric and Kevin have good advice. The thread Kevin linked to can show you a simple fix for your code if you understand what's going on. |
Re: Jiggly servo
Alan, I agree. We did have two buttons setup for the drivers, but they asked for a single button shift.
I really did not understand the threads. We don't have any trained talent on the programming team. We don't offer a class at our high school and we don't have any outside mentoring to help us learn. Everything we know we have learned through LVMastery and ChiefDelphi. We will try Alan's "rising edge" program. We don't understand the logic in it, but I have seen the icons before. |
Re: Jiggly servo
Quote:
So the code outputs true if and only if the button is pressed now and wasn't pressed the last time the code executed. |
| All times are GMT -5. The time now is 11:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi