Need help with the basics...

450nick

New Member
Hi all,

I've just got hold of a picaxe developers board with which to test and program some chips. I've written a couple of simple programs in the software and in the simulator they work perfectly, just as I want them to.

I'm currently just using a switch and two leds to test out some functions. I then send the program to the 18x chip and it says downloaded successfuly. I've wired up the chip to the leds and sw1 (I think) and all that happens when I press sw1 is the led lights, for as long as I press the button (in this case it should flash).

I'm sure its because I've put the jumpers in wrong but I can't find any sort of guide or instructions to learn from... Does such a thing exist?

Nick
 

Rickharris

Senior Member
Hi all,

I've just got hold of a picaxe developers board with which to test and program some chips. I've written a couple of simple programs in the software and in the simulator they work perfectly, just as I want them to.

I'm currently just using a switch and two leds to test out some functions. I then send the program to the 18x chip and it says downloaded successfuly. I've wired up the chip to the leds and sw1 (I think) and all that happens when I press sw1 is the led lights, for as long as I press the button (in this case it should flash).

I'm sure its because I've put the jumpers in wrong but I can't find any sort of guide or instructions to learn from... Does such a thing exist?

Nick
Before you go too far check your programme for the following:

Code:
start:
high 1  ' turn LED on
wait 1   'wait for 1 second
low 1  ' turn LED off

goto start

IF you do this you turn the LED on wait for 1 second and turn it off BUT almost instantly turn it back on again - You need another wait AFTER the low to turn it of of you will not see the flash - It happens too quickly for your eye to see.

Code:
'correct code

start:
high 1
wait 1
low 1
wait 1
goto start
 

450nick

New Member
Here's the control code I'm using...

Code:
symbol LED = 0
symbol relayout = 1


buttonpress1:	
	if pin1 = 1 then 
	goto turnon
	else
	goto buttonpress1
	endif
	
	
buttonpress2:	
	if pin1 = 1 then
	goto turnoff
	else 
	goto buttonpress2
	endif
	
turnon:
	high relayout
	high LED
	if pin1 = 0 then
	goto buttonpress2
	else
	goto turnon
	endif
	
turnoff:
	low relayout
	low LED
	if pin1 = 0 then
	goto buttonpress1
	else goto turnoff
	endif
As I said, its pretty simple, but seems to work fine in simulation. Just need to get it to work on the developer board before I try it in a test circuit....

I'll give the short code a try to test the board out... It should work though as it returns the firmware version without any problem and the program downloads without fault...
 

MPep

Senior Member
Can you post a circuit diagram of the circuit you actually have?
It could be something as simple reading pin1 as being the same as leg1.
LegX is the physical pin of the chip, whereas PinX is the System's number which could be on Leg4 for instance.
 

450nick

New Member
Ah right, I will have a go at using the leg command instead... If that doesn't work, I'll get a diagram up of what I have.
 

450nick

New Member
Right, got the test script to work fine, and so I added a wait 2 command to the beginning of the program. Sure enough, the led didn't come on for two seconds but then stayed on permanently... So it must be my programming...

Can anyone see what is wrong with it? It seems to think that the switch is always active even when it isn't. Works fine in the simulator though??
 

MartinM57

Moderator
Can anyone see what is wrong with it?
Not without seeing it ;)

Unless you expect us to expend effort/guess what edits you've made to the code since the last post of it and imagine what the circuit diagram is.

Help us to help you...and we'll no doubt oblige...
 

hippy

Technical Support
Staff member
Take it step at a time, get the foundations built before trying to build a skyscraper upon them. First run a program as Rickharris shows in Post #3 ...

Symbol LED = 0
Do
Toggle LED
Pause 1000
Loop

The LED should flash on and off for one second at a time.

Then move on to checking the input ...

symbol LED = 0
Do
If pin1 = 1 Then
High LED
Else
Low LED
End If
Loop

The LED should come on when you push the button, be off when you don't.

Repeat, replacing "Symbol LED=0" with "Symbol RELAY=1", with the relay output pin (1) taken to a LED.

Disconnect all other connections to the board, and in particular don't connect the relay until the above tests are working.

When you have the button test switching the LED which would be a relay, connect the relay and check it still works; button pushed relay activated, button released no activation. If not there's probably some circuit error with your relay.
 

450nick

New Member
Sorry guys, I've been trying to rush it a bit as I've not had much free time lately... I'll sit down with it properly later on tonight or tomorrow and take some photos, try the step by step method and report back...
 

eclectic

Moderator
Sorry guys, I've been trying to rush it a bit as I've not had much free time lately... I'll sit down with it properly later on tonight or tomorrow and take some photos, try the step by step method and report back...
Quick question.
Andrew C asked in post #2:

What "developers board" are you working with?

e
 

450nick

New Member
Right, after a busy few days, I'm back to trying to figure out the world of picaxe...

In answer to the last question, I'm using the axe 091 developer board. I've tried a few of those basic programs and I can get the led to flash no problem. So I've traced the problem to the buttons. Regardless of the progam I use, when I press the button the led comes on and when I release, it goes off...

Now I'm sure the board wasn't broken when I bought it, and the program I am trying works fine in the simulator, so it must be my wiring of the board.

So here is what I'm working with at the moment:



Sorry about the terrible excuse for jumper leads... I will pick up a pack of proper ones from Maplin when I next go in.

Essentially, all I have done is wire the output pin directly to the led, and the button directly to the input. (in0 and out0). To begin, I just want the led to come on when I press the button once, and go off when I press it again...

So I'm hoping now that you'll all at once point out that I've wired it completely wrong and its an easy fix...?!
 

BeanieBots

Moderator
Hard to make out from the picture but it looks like:-
leg 18 (pin1) goes to breadboard then nowhere.
Switch goes to breadboard then nowhere.
LED goes to leg6 (0v) but it might be leg7 Output 0

Try connecting the two connections on the breadboard which go nowhere!
That should then link the switch to input 1.

EDIT:
The breadboard links in blocks of 5 UP/DOWN the board.
Only the top two and bottom two rows link left/right and are usually used for power/0v.
 
Last edited:

450nick

New Member
Ahhh, I thought the breadboard had lines running from left to right! I'll go make myself some more home made jumpers which avoid the breadboard...

So if I were to make a circuit in the middle of the breadboard, do I have to put a bridge every 5 pins? Is there a pic anywhere of what the tracks look like under the board?
 

BeanieBots

Moderator
The tracks are as I just described.

The very top two and very bottom two go left/right. (all blocks of 5 are connected together on those strips).
All the bits in the middle are in blocks of 5.
Thus, if you put a chip in the middle across the central gap, each leg will have 4 connections available going up/down.
 

450nick

New Member
Thanks guys, that helps a lot! It would really help if they included a little picture like that in the instructions...!
 

inglewoodpete

Senior Member
As an aside, I notice from the photo that you're using stranded hookup wire for connections. Not really suitable.

You should be using solid core wires with a breadboard. You can buy packs of ready made breadboard wire from most hobby-electronic shops. Alternatively, buy a metre of multi core cable (Eg Cat 5 or 6) and cut the core wires into suitable lengths - but make sure it has solid conductors, or course.
 

450nick

New Member
Yes, sorry I did mention earlier in the thread, I know multi-core is a rubbish way of doing it, but its the only wire I had around. I'm back in my normal office today and there's a Maplins across the road so I'll pick up some jumpers when I finish work...
 
Top