Australia
Asked — Edited

Adc Ports

I just want to confirm, so as to NOT release the magic smoke, I want to trigger scripts wit the press of a button or the closing of a normally open contact. I figure that I connect the Red (3.3 Volts) and White (signal) on an ADC port across the switching contacts and have a script watching the assigned ADC port for change. I also planned to connect a pull down resistor across the signal to ground to keep floating voltages in check.

Is the above correct?

Also I may need a little help with scripting, How do I wright a script to watch and wait until the contact is closed, or opened again for that matter? I need the script to pause the personality generator at least and then I can build on it from there.

Thanks for any help in advance

Steve


ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

#1  

I'm not totally sure about the wiring, though it makes sense.

As for the code, an if/else statement will do:

IF (getADC("A0") > 30)
  $button1 = 1

ELSE
  $button1 = 0

ENDIF

Change the ADC port to the one you will be using. This should work.

PRO
Synthiam
#2  

Also you will need a resistor to pull down to gnd so it doesn't float. Otherwise the adc will pick up static electricity in the air.

#3  

@DJ Could you draw a little diagram of this, or take a picture? I also want to do something like this.

#4  

Or something like this maybe?


:top
$button1 = 0
ADC_Wait (adco, Higher, 30)
  $button1 = 1 
# button pressed so go do stuff 
goto(top)

#5  

For a simple on-off button, can't you use a digital port and the GetDigital(port) command? Would be 0 when open and 1 when closed?

Alan

#6  

I've done this exact same thing with great success with the chest buttons on my B9. You're completely correct in how to wire it. Run one wire from the power pin from the ADC port of ezb to one side of the momentarily button, a second wire from the signal pin of ezb to the other side of the button. Then you can attach a 10k resistor from either the signal wire or power wire to ground (I simply attached to the ground pin of the same ADC port). The power or signal wire you attach to will determine whether it's a pull up or pull down.

Richard's script suggestion is a good way to do monitor the port to trigger a script. I may change some of my scripts to this method. However if you want the same switch to do multiple things like check and uncheck the personality generator then you need to be more creative. In this case I'll set a vearable of either on or off each time I push that button. With an if statement in a script I can check the status of that vearable and do different things like turn that control on and off. If you want, download my latest B9 project from the ez cloud and look at the first few scripts in the script manager. I can't offer the link right now. Sorry.

PRO
Synthiam
#7  

R1 can be 10k. If you are out of digital ports, the ADC will work. A simple script as demonstrated above will work. Loop and check for the ADC voltage to be greater than 0

Pull Down Example (recommended for this application) User-inserted image

Pull Up Example (opposite of pull-down) User-inserted image

Australia
#8  

Thanks everyone :) I feel much better knowing I'm not going to blow up my EZB. I've done enough damage for this month on my B9 project,....breaking the neon while installing it,.... tired Dave knows what I'm talking about. ;)

Dave, I did have a quick look at your projects, but I will need to spend more time to understand them. I am away on Holidays at the moment, (Port Douglas... beautiful spot in north Queensland), so I cant do anything practical until I get home. When I did have a look though, I couldn't seem to find the "Script Manager". It occurred to me after that there may be more than one page in your projects. When I get home I will have a "Women's look" instead of a "Mans look" ;)

Thanks again everybody for your responses, I'm off to enjoy the beautiful Sun, beaches and girls in bikinis

#9  

When you loop your script make sure you place a Sleep() command in there or you'll overwhelm your system and everything will come to a stop. The longer the pause the better and still have a quick enough responce for your taste. Try starting out about 0250 or less and work up from there. You my find a full second may seem like a sluggish responce when you push your button. Here's one of my scripts I use to toggle the personallity generiotr on and off when pushing a momentery button attached to an ADC port. Perhaps it could be written better but it seems to work nice for me with no problems:


:Start

$adcpersonalitycurrent = GetADC(adc2)

IF ($adcpersonalitycurrent > $adcpersonalitySpecified) #$adcpersonalitySpecified is set in the initscript and it triggers the script to move on when the ADC value raises above it.  
  goto(PersonalityToggle)
ELSE 
  Sleep(1000)
  Goto(Start)
ENDIF 
goto(Start)

:PersonalityToggle
IF ($Personality=1)
  ControlCommand("Speech Recognition", PauseOff)
  $Speech=0
  Sleep(7000)
  Goto(Start)
ELSEIF ($Speech=0)
  Goto(PauseOn)
ENDIF 
  
:PauseOn
$Personality=1
ControlCommand("Personality Generator", PauseOn)
Sleep(6000)
ControlCommand("Soundboard v4", Track_24)
Sleep(6000)

ADC_Wait(ADC2, Higher, 220, 1000)
ControlCommand("Personality Generator", PauseOff)
$Personality=0

Sleep(5000)
ControlCommand("Soundboard v4", Track_23)
Sleep(5000)

goto(Start)

#10  

I loved Queensland when I was there a few years back. I spent a couple days scuba diving the Great Barrier Reef off of Mackay from a catamaran. I understand why it's one of the wonders of the world now. I actually slept on the beach one night and watched the stars and listened to the ocean. The month I spent in your country was one of the best of my life.

Lots of stories to share but this is kinda off topic. Forgive me. Can't help it. I have to talk about my time with your people down under when I get a chance. :)

Australia
#11  

Thanks for all your help Dave :D No need for apologies, go off topic any time you want. I scuba dived at the Great Barrier Reef too some years back, incredible springs to mind. Never slept on a beach under the stars though...sounds awesome

Catch ya soon mate

Steve

Australia
#12  

GetADC( Port ) Returns the 8 Bit ADC value of the specified port Example: $x = GetADC(adc0)

I am having trouble with the above as I cant seem to figure out how to nominate which EZB board I am using. I have 2 EZBs and I want to monitor Port 0 of Board 1. I know the (adc0) refers to port 0 but how do I tell it to use board 1

Steve

#13  

From the EZ-B script manual:

Quote:

ARC supports multiple physical EZ-B Boards connected to your computer. You can specify the board by putting the board number in front of the port. For example: Servo(2.d0, 8) will move the D0 servo on EZ-B board #2 to position 8. If no board index is specified, the first board (zero) is assumed. If using more than one board, the first board is always responsible for movement panels.

So, for your example it would be $x = GetADC(1.adc0)

Alan

#14  

Actually Alen $x = GetADC(1.adc0) would be the 2nd EZB . The first EZB would be zero (0). You don't have to state that board. you would just write it like Steve shows it: GetADC(adc0)

Australia
#15  

Thanks guys, I think I tried nearly everything. The only difference between one of my many, many failed combinations and yours was I had a comer between the 1 and adc instead of a full stop. I will give that a try

Steve :)

#16  

Quote:

Actually Alan $x = GetADC(1.adc0) would be the 2nd EZB . The first EZB would be zero (0). You don't have to state that board. you would just write it like Steve shows it: GetADC(adc0)

yeah, I assumed he knew that board 1 is the second board because he specifically referenced it, and since I quoted the EZ-B manual section that explains the board numbering, but in case my assumption was wrong, yes, if you don't specify a number, it will choose board 0, the first board.

Alan

Australia
#17  

Thank God!

That "." instead of a "," made all the difference. This problem has been kicking my butt for nearly a day

Thanks again guys

Steve

#18  

Glad you got through this problem Steve. These little things are flusterating. When a script doesn't work for me the way I think it should the first thing I look at is the sentence structure.

It's all good Alan. I was the one who was confused. You knew exactly what you wanted to say. ;)