Jaychadw
United Kingdom
Asked
— Edited
Is it possible to add a push button switch, even going as basic as two wires that connect via pushing. Also how do I add a variable resistor. Also will a basic dimmer switch work as a variable resistor? I know these may seem like really daft questions but it helps me alot. Can someone please talk me through it.
What do you want the push button switch to do? Yes you can add one but without knowing where you want to add it we can't help tell you how to do it. Same for the resistor really.
The variable resistor is going to return the position of a joint as the joint is going to be powered by a motor with a reduction gear system. The switch is going to be used to detect when a weight is put into a panel. The switch being placed under it. Not a toggle switch of any kind. The panel will be pushed up with springs, when enough weight is added onto the panel, the switch is triggered. The same switch type I was thing could be added to a foot to detect when the foot is placed onto a surface. Triggered when down for example
Dave has used pots on his B9 to find the position, I'm not sure if he has documented it but it'll be worth looking at his B9 project. I think Lumpy has also used the same on his R2D2. I'm not sure if a dimmer switch can be used, I'd guess no but I'm not certain at all.
As for digital switch, yes. Easy. 2 ways to do it, either on the Digital ports or the Analogue.
Analogue, simply put the switch between Signal and Vcc. When it's closed and makes contact it will send 5V to signal giving an ADC value of 255. GetADC(adcport) will give the result.
Digital, almost the same but it's 0 or 1 and can use the Digital Read control or script function.
Script examples;
Excellent thank you. I will look into those they are great. Would that work for variable resistors
I believe the ADC one would. As the resistance increases the ADC decreases. Then just have your ifs for specific values or ranges;
Yes, I am using both methods on my B9 and they work great. The ADC method as Rich describes for push buttons is a good choice. I have several set up like this. Also the Pot (variable resistor) worked better then I had imagined it could. In my scripts to control and monitor the turning of my waist and radar sections I use Variables and Math to find the stop points from readings sent back from the pots through the ADC ports on EZB. You can send an $adcRdrSpecified from any other script or command to get the rotation to stop at any point along the radius. For example:
I've even had great success at ramping the start up and stop of rotation by adding multiple PWM commands, one a little higher then the preceding one at the same time I send the variable command to the movement script. I still need to refine the process. Seems a smaller radius needs different tweaking then a mush larger one. Here's an Example:
I still need to sit down and clean up all my scripts and my entire B9 project. I have lots of unneeded lines and controlls and junk everywhere. I also need to move my scripts over to the Script Manager but everything seems to be working well for now. I have a lot of actual wrench turning to to on the robot it's self and work on ARC when I want a break or want to see him gain more personality.
Your free to use any of my scripts and I'll help if I can (if I see your post). Rich seems to be the script master around here. In fact I was thinking of asking him to go over my scripts when I cleaned them up a bit to see if there were any way to make them better.
Here's a link to my project thread with lots of pics and vids (including lots of the pots and how they work): My B9 project
Here's the latest copy of my project: B9RobotControl.EZB
Good luck and have fun! Dave Schulpius
Thank you so much Rich and dschulpius. That was exactly what I needed to know. Thanks also for the code snippets, I'm writing in c# but I can work it out from there. I'm still testing all these things and when I've put them together I look forward to sharing my project with you all.