I have so many questions I am a complete newbie!!!

beaniecrocker

New Member
Can anyone tell me first off if when I hook a tact switch up to an input does the other end just hook to a ground or does it need to connect to a power source.... The other is a programming issue I just taught myself how to program by reading the manuals in the programming editor for 6 hours between reading and programming at the same time and I was wondering why only 1 output is working on my breadboard and the program is not running off of my switch pin3...here is my prog.


symbol rfbutton = pin3



main:
pause 150
if rfbutton = 0 then rf1
goto main

rf1:
high 1
high 0
pause 22
low 1
low 0
pause 18
high 1
high 0
pause 22
low 1
low 0
pause 18
high 1
high 0
pause 22
low 1
low 0
pause 18
high 1
high 0
pause 22
low 1
low 0
pause 18
if rfbutton = 1 then goto rf2
goto rf1


rf2:
high 1
high 0
pause 100
low 1
low 0
pause 100
if rfbutton = 1 then goto rf3
goto rf2


rf3:
for b0 = 1 to 3
high 1
high 0
pause 50
low 1
pause 50
if rfbutton = 1 then goto main
next b0
goto rf3




end

It works in simulation but when I put it to the breadboard or in use It just doesn't work right
 

lbenson

Senior Member
A normally off pushbutton switch will be tied to ground with a high-R resistor to prevent transients from triggering it falsely, with the other end tied high.
Code:
        _|_
4.5V ---- ----o---pin3
              |
              -
             | | 100K
              -
              |
              0v
Reverse 4.5V and 0V with a normally high switch.
 
Last edited:

Andrew Cowan

Senior Member
That makes a potential divider. For the resistor, 10K is the most common value, although you can go high (power saving). I don't recommend going lower.

Replace the switch with an analogue sensor (eg light), and you can measure light levels via an ADC input!

A
 

chigley

Senior Member
A normally off pushbutton switch will be tied to ground with a high-R resistor to prevent transients from triggering it falsely, with the other end tied high.

[...]

Reverse 4.5V and 0V with a normally high switch.
Do you do those ASCII circuit diagrams manually!? Must take ages...

EDIT: beaniecrocker, I'm not sure if this is deliberate, but your second line reads:

Code:
if rfbutton = 0 then rf1
Which would mean that output 1 would be powered when the button isn't pressed, is that what you wanted?
 

westaust55

Moderator
beaniecrocker,

Welcome to the PICAXE forum - even if you have already been here for a few days.

Have alook at PICAXE Manual 3 for hardware interfacing guidelines.

A nice clear picture on how to conenct a switch on page 25.

For the LDR, that Andrew has mentioned, look at page 28.

There is a link [PICAXE Manual] in to orange tookbar at the top of the forum pages to the PICAXE manuals if not already downloaded/read manual 3.
 
Last edited:

Dippy

Moderator
Andrew, are you referring to Ibensons' sketch when you say "That makes a potential divider" ?

Please explain, as that has confused my lager-riddled cerebellum.


I thought it made a perfectly clear diagram of how to do a switch or am I looking at the wrong picture?

The choice of the resistor value is down to the application.
In a PIC circuit I have done recently I've used 1M5 resistors.

When a PIC pin is in 'Input' mode the impedance is very high anyway, so that resistor value has little significance in most basic cases. However, I agree there is little point going lower than 10K.

However, the higher the res value then the more susceptible it is to noise.

BOttom line: read all the advice above and read the manuals. Most of the basic stuff is covered in them.
 

westaust55

Moderator
Andrew, are you referring to Ibensons' sketch when you say "That makes a potential divider" ?

Please explain, as that has confused my lager-riddled cerebellum.
.
Andrew is right in a sense. :rolleyes:

Switch open and the divider comprises infinity Ohms and 10kOhm ==> 0V
Switch closed and the divider comprises 0 Ohm to 10 kOhm ==> Vcc

Not what I would class as a potential divider but the theory is right.

Agree that 10 kOhm is not always the best value but a fair/typical starting point.

On a previous LDR, a found 22kOhm was the optimal value to maximum voltage range into an ADC channel.
I have just bought some more LDR's and after measuring their resistance, 2.2kOhm was the ideal value and I get a range of 7 to 250 with READADC.
 
Last edited:

BeanieBots

Moderator
When using potential dividers for analogue inputs, don't forget about PIC datasheet values for maximum source impedance!
 

Dippy

Moderator
Blimey, that reeeeeeeaaaaaalllllllyyyyyy is being pernickety to a near-infinite degree.

No normal person in normal circumstances would agree, except my old solid-state Physics Prof lecturer and he was right old train-spotter ;)
 

beaniecrocker

New Member
Well I have another Q: What is the minimal amound of v needed to power on an 08m? I know you need 5v to download a program, but can it be lower to run a program?
 

hippy

Ex-Staff (retired)
A 08M can run right down to 2V and possibly even lower if you are lucky although that would not be recommended and spurious and unpredictable operation may occur.

While developing and testing it is recommended to run at a voltage with a good headroom above minimum ( 4V5, or 5V ). Once the system has been proven to work reliably its operation at lower voltages can then be assessed. The last thing you want when trying to test something is having unreliable operation which may look like programming or system design issues when it is simply down to operating at low voltage.

When operating at lower voltages and interfaced to other components you have to pay close attention to the voltages where logic switch points will be for Schmitt inputs.
 
Last edited:

Buzby

Senior Member
Slightly off topic, but related to Hippy's warning about Schmitt levels.

Many years ago I worked for a manufacturer of domestic electronic equipment. Their latest design had been extensively prototyped and worked perfectly. Orders were placed for 10,000 sets of PCBs and parts, including custom analogue chips that had open collector outputs, which in turn connected to the inputs of a mask programmed MCU. The first 1000 production units were built, and none of them worked.

Nobody had read the chip manufacturer's spec sheets properly. The open collector output could have an 'on' resistance as high as a few hundred ohms, and the MCU's interal pullups could be as low as 1K. All the devices used for prototyping were well away from these values, so everything worked fine. The 10,000 sets then ordered came from batches where the tolerences were all at the 'wrong' ends, and so the O/C output couldn't pull the MCU input down low enough to switch. No one to blame but the designers.

So make sure if your design depends on something like an internal pullup that you build for all possible combinations of manufacturing tolerances.
 

BeanieBots

Moderator
Well said Buzby, all too often on this forum the response to a "proper" design or caution is "I did it this way and it worked fine".
I'm sure did, THAT time.
 

George Sephton

Senior Member
Just to say you have pause 22 and stuff like that, a pause is measured in milliseconds (or micro?) so 22 milliseconds is really short and that may be why you see no difference.
 
Top