Correction in a few spin commands for input/output needed please
Dan E
Posts: 61
Hi,
I modified some langauge in a debounce button object that was originally written by another forum member to help me rotate a servo clockwise and counterclockwise by pressing one of two buttons, one for each direction.
I now am trying to use two other buttons to turn on and off a piezo buzzer. I commented the code that I added with descriptions of what I was trying to accomplish. I ran the code and no buzzer resulted. I am still very new to the Spin langauge, and the few lines I wrote seemed logical, but it is not correct.
I have an ultrasonic rangefinder that has its PWM output going to the propeller. The code I added says for a piezo buzzer to sound whenever the PWM is at a high state. Since the period of the PWM will change with the distance of the object detected by the rangefinder, I assumed the pitch of the buzzer would change as a result. I added a delay after the buzzer first sounds, then it is to shut off, wait, then repeat. This is so that there will be a noticeable beep, so that it would be easier to determine a change in pitch.
The purpose of this is so that a group of blind students can have audible clues where to aim a bowling ramp, so that they can locate the closest pins.
The first debounce button turns on the buzzer, below is the code I wrote for this action:
The second debounce button is to silence the buzzer, below is the command I wrote for that:
From what I read in the manual, these commands seem to be accurate, but possibly they are meant for a different type of statement.
I attached the full object so people can see the context of how I would like to use these commands.
Aim guide - Archive [Date 2011.01.20 Time 01.00].zip
If the logic of having the varying PWM input to the propeller change the pitch of the piezo buzzer isn't realistic, then I would truly appreciate some suggestions as to how I could accomplish this. Also if someone could point out the error in the few commands I contributed, because the program compiled so I am unable to determine where the error is, and I would like to learn so that I don't do it again.
Thanks,
Dan
I modified some langauge in a debounce button object that was originally written by another forum member to help me rotate a servo clockwise and counterclockwise by pressing one of two buttons, one for each direction.
I now am trying to use two other buttons to turn on and off a piezo buzzer. I commented the code that I added with descriptions of what I was trying to accomplish. I ran the code and no buzzer resulted. I am still very new to the Spin langauge, and the few lines I wrote seemed logical, but it is not correct.
I have an ultrasonic rangefinder that has its PWM output going to the propeller. The code I added says for a piezo buzzer to sound whenever the PWM is at a high state. Since the period of the PWM will change with the distance of the object detected by the rangefinder, I assumed the pitch of the buzzer would change as a result. I added a delay after the buzzer first sounds, then it is to shut off, wait, then repeat. This is so that there will be a noticeable beep, so that it would be easier to determine a change in pitch.
The purpose of this is so that a group of blind students can have audible clues where to aim a bowling ramp, so that they can locate the closest pins.
The first debounce button turns on the buzzer, below is the code I wrote for this action:
The second debounce button is to silence the buzzer, below is the command I wrote for that:
From what I read in the manual, these commands seem to be accurate, but possibly they are meant for a different type of statement.
I attached the full object so people can see the context of how I would like to use these commands.
Aim guide - Archive [Date 2011.01.20 Time 01.00].zip
If the logic of having the varying PWM input to the propeller change the pitch of the piezo buzzer isn't realistic, then I would truly appreciate some suggestions as to how I could accomplish this. Also if someone could point out the error in the few commands I contributed, because the program compiled so I am unable to determine where the error is, and I would like to learn so that I don't do it again.
Thanks,
Dan
Comments
I still wasn't able to get to buzzer get the buzzer to operate, but I did some debugging, and I'm pretty sure I know why, and this time i'm sure its not the code.
The PWM input to the propeller from my ultrasonic rangefinder reads as is:
120mV when I hold my hand up to a foot away from its sensor
370mV high when I emove my hande and the signal bounces off the ceiling, which is about 6ft above the table I tested on.
410mV when I pointed the sensor out the window, which I think it picked up some trees about 8 feet away, so I couldn't get a realll long distance observed.
The typical distance of the final application will be from 10 to 20 feet. I also measured 0 volts coming out the pin that is to power my piezo buzzer.
I'm pretty sure this tells me that there is not enough voltage going to the input pin to switch the state to high. I held the debounce button in, and also just quickly pressed it to confirm that the result was still no voltage being outputed to the buzzer.
I wrote a new program that just tests what I am trying to do, minus the debounce buttons, so that I can eliminate sources of possible error. Same deal.
Buzzer and Rangefinder Test - Archive [Date 2011.01.20 Time 17.39].zip
To further debug, I attached 3.3v directly to the input pin, and the buzzer sounded.
What I can guess from this is that more voltage is required to be detected as an input, than what is coming from the PWM output?
What is the minimum amount of voltage needed to switch an input from a low state to a high state? Also, what is the maximum, so i don't burnout the chip inadvertantly?
I hooked up different voltages to the buzzer, and it beeped with different amplitudes rather than changing the pitch as I had hoped.
Anyone have any suggestions on how to change the pitch to correspond with PWM input?
Thanks,
Dan
Basically with the combination of the ultrasonic rangefinder and the piezo buzzer, I am trying to make a proximity detector.
So it seems in order to make this happen, I need to have the 'waitcnt' vary as the PWM input varies.
The voltage from the rangefinder will most likely be varying from about 200mV to 500mV so I would have to write an equation to scale those values to a set of increments that made sense.
Is it possible to take the magnitude of the PWM input and have it be the varying factor of the 'waitcnt'??
Can the Propeller pick up readings that low in voltage as in input?
Thanks,
Dan
Dan