Where to start (beginner)

Jarubell

Senior Member
Update:

Well I finally had time away from the family, found my soldering iron for the breadboard adapter and gave it a shot. Uploaded (downloaded?) my simple program to the pic and it worked, well, sort of, it does not do the same thing as the simulator but still, I made some progress with my little 08M!

Should the 08M work at the same speed as the simulator?

Thanks guys, I off to find my multimeter! Should be somewhere.
 

tjetson

Senior Member
Update:

Well I finally had time away from the family, found my soldering iron for the breadboard adapter and gave it a shot. Uploaded (downloaded?) my simple program to the pic and it worked, well, sort of, it does not do the same thing as the simulator but still, I made some progress with my little 08M!

Should the 08M work at the same speed as the simulator?

Thanks guys, I off to find my multimeter! Should be somewhere.


I know you can slow down the simulator, not sure if you can make it go faster than the code would execute on a picaxe though.
 

hippy

Ex-Staff (retired)
Programs running in a PICAXE may be much quicker than when simulated as simulation has to slow execution down so you can see things happening.
 

lbenson

Senior Member
What differences are you seeing (post your program)?

An 08M may execute around 4000 instructions per second (exclusive of things like PAUSE); the simulator no more than a handfull per second--you need to be able to see what is happening in the simulator.
 

Jarubell

Senior Member
All I was trying to do is have three leds that with an input will switch to the next LED

Code:
setint %01000,%01000 	
let dirs = %00010111		

main:
	if b1 > 3 then number0
	if b1 = 1 then number1		
	if b1 = 2 then number2
	if b1 = 3 then number3
	goto main					

interrupt:
		
	high 0		
	pause 1000 	
	if pin3=1 then interrupt
	low 0			
	setint %01000,%01000
	b1=b1+1	
	return
	
number0:
	b1=0
	goto main
	
number1:

	let pin1=1
	pause 1000
	let pin1=0
	goto main
	
number2:

	let pin2=1
	pause 1000
	let pin2=0
	goto main
number3:

	let pin4=1
	pause 1000
	let pin4=0
	goto main
I'm working on it, maybe it's also my wiring.
 

MartinM57

Moderator
Just passing by (in a hurry). From the SETINT command in Manual 2...
Code:
1) Every program which uses the SETINT command must  have a corresponding interrupt: 
sub-procedure (terminated with a return command) at the [B][I]bottom of the program.[/I][/B]
I've often wondered why, and it may or may not be your problem...
 

hippy

Ex-Staff (retired)
The interrupt doesn't have to be at the bottom of the program, though it will usually be placed there, and many will expect it to be there.

The program looks okay to me so perhaps we need a better descriprion of how the speed differs. The program uses "PAUSE 1000" throughout so those are pauses each one second long. Perhaps that's the issue ?

If the switch connected to pin3 doesn't have a pull-down resistor it could be that the hardware input pin is 'latching' and the interrupt is jamming up after the switch is released.
 

Jarubell

Senior Member
Hippy, I been reading other posts and noticed that you have mentioned pull down resisters more than once. No, I do not have a pull down resistor and when I get another chance, I going to look in the manuals regarding this the next chance I can.
 

hippy

Ex-Staff (retired)
Take a look in PICAXE Manual 3 ( via Help in Programming Editor ). That will show how to wire the switch up.
 

Jarubell

Senior Member
Hippy, thank you for directing me, I clearly screwed up my wiring and never thought about the switch wiring. Going to try that tonight, well tonight here in Canada.
 

westaust55

Moderator
The interrupt doesn't have to be at the bottom of the program, though it will usually be placed there, and many will expect it to be there.
Very true hippy, but I guess many adhere to the manual (see Manual 2 V6.9 p.181) which clearly states:
Notes:
1) Every program which uses the SETINT command must have a corresponding
interrupt: sub-procedure (terminated with a return command) at the bottom of the program.
 

Jarubell

Senior Member
Hippy, it works great now that I installed the pull-down resistor and now I searching the site here to find out why it is required.

westaust55, I now see what you posted. I did read that but all I took from it was the required "return".

Thanks for everyones help.

ps, my interrupt is now at the end!
 

BeanieBots

Moderator
it works great now that I installed the pull-down resistor and now I searching the site here to find out why it is required.
Think of it litterally in terms of a mechanical device.
Your switch pulls the input up.
When you turn the switch off, what happens?
If there is nothing to pull it back down, it will just stay there.

In practice, just like in the real world, things are not perfect and just like there is in real life, there will be a breeze blowing. (electrical noise).
If you think of your input like a balloon, with nothing pulling it in any direction, it will float away in a random direction. (that's why a disconnected input is described as floating).
 

Andrew Cowan

Senior Member
The 10K is to stop it floating. What is the 1000 you mention? If you are refering to the 'PAUSE 1000', it's to debounce the switch.

A
 
Last edited:

Jarubell

Senior Member
Andrew, I mean the 1k resistor that I installed on the input for the switch.

oh, I had the pause at 1000 just for the simulator, I now have it at 100 and who knows may not even be required with my setup and switch.
 

BeanieBots

Moderator
Assuming the 1k is in series with the input, then it is to protect the pin if it accidentally becomes an output and the switch is closed.
 

hippy

Ex-Staff (retired)
The 1K serves two purposes - it helps protects the PICAXE input from ESD ( static discharge when you push the switch such as after shuffling over nylon carpet in woolly socks ) and also protects should the PICAXE input become an output and the the switch pushed, which would short it to 0V or 5V.

The 1K may be reduced or left out when prepared to accept the lower protection.
 

Jarubell

Senior Member
Great Thanks.

I have another simple non picaxe relate question, breadboards. THis breadboard I have has a sticky back and a same sized sheet of metal, what is the metal for?

Also, I starting to look at transistors, just to see how to use them. So I see there is many options, what would I use to just switch a low voltage or do I need to ask my self more questions?

Side note, I picked up a piezo buzzer and it now has become my favorite annoying toy.
 

lbenson

Senior Member
"The Source" (3 locations in Dartmouth) might have this pack of 15 general purpose NPN transistors for $5.99 (I couldn't find a part number): http://www.thesource.ca/estore/product.aspx?language=en-CA&product=2761617&category=Semi+Conductors/IC's&catalog=Online&tab=1#more

Or this pack of PNPs: http://www.thesource.ca/estore/product.aspx?language=en-CA&product=2761617&category=Semi+Conductors/IC's&catalog=Online&tab=1#more

If you want more specific parts, http://www.futurlec.com has a selection at reasonable prices--but long shipping times to Nova Scotia.

Here is a standard "low-side" switch with a small "signal" (as opposed to "power") NPN transistor, e.g. a 2n3904 or a 2n2222. LED connects to the Collector, 0V to the Emitter, and the picaxe pin to the Base.

Code:
                     C   E
+5V-----330R---LED---o   o---0V
                       o 
                       | B
picaxe pin----1K-------'
You can find datasheets for various transistors at www.digikey.ca or www.jameco.com or many other places.
 
Last edited:

Jarubell

Senior Member
Thanks lbenson

I picked up that 15 pack of NPN transistors but since I'm working away from home, I have not had no time to try them.

How about free circuit drawing programs? Do they exist?

James
 
Top