18 x triggers 20 m

rob nash

Senior Member
A warm hello,,,let me start by confessing am lower than newbee,, and expect to finish manuel 2 somtime around 2012,,although i spend hours reading it,,,slowly trickles in, am using the axe 91 dev/board... hours of fun?/bread boards...
my project has a several parts to it,,
On the axe 91 is pic 18x wth a simple programme

main: high 2
pause 10000
low 2
pause 15000
goto main

this triggers the pic 20m onthe bread board with the programme ' projet cylon eye
'written 6/9/09
'picaxe 20M


symbol counter = b1


main:
readadc 0,b0
if b0 < 90 then cylon
if pin2 = 1 then cylon
goto main


cylon:
for counter = 1 to 10
high 0,1
pause 50
low 0,1
pause 50
high 1,2
pause 50
pulsout 0,200
pulsout 1,200
low 1,2
pause 50
high 2,3
pause 50
low 2,3
pulsout 1,200
pause 50
high 3,4
pause 50
low 3,4
pause 50
pulsout 2,200
high 4,5
pause 50
low 4,5
pause 50
pulsout 2,200
pulsout 3,200
pulsout 4,200
high 5,6
pause 50
low 5,6
pause 50
high 7,6
pause 50
low 7,6
pause 50
pulsout 4,200
pulsout 5,200
high 6,5
pause 50
low 6,5
pause 50
pulsout 6,200
high 5,4
pause 50
low 5,4
pause 50
pulsout 6,200
high 4,3
pause 50
low 4,3
pause 50
pulsout 5,200
high 3,2
pause 50
low 3,2
pause 50
pulsout 5,200
pulsout 4,200
pulsout 3,200
high 2,1
pause 50
low 2,1
pause 50
pulsout 4,200
pulsout 3,200
pulsout 2,200
high 1,0
pause 50
low 1,0
pause 50
high 0
pause 50
pulsout 2,200
pulsout 1,200
low 0
pause 50
next counter
goto main

the programme isn't finished may not fit on the 20m???

is there another way off writing this programme,,as this is taken nearly all the memory


also i observed that i powered on the axe 91 and this triggered the bread board and 20 m is working without power leg being conected

the only conection is outpin2 on 18x conected to pin2 20 m pin2 held low by 330r and the 0v back to axe 91,,,

Q) i am heading towards doom wth this setup as did,nt expect this result,,,

kind of hoping someone can give advice on the cylon proggrame to sorten it
 

Attachments

Andrew Cowan

Senior Member
It has been noted here before that it is possible to power chips this way (through an input). However, it can't be good for the chip, so it is best to put a proper power line on the chip.

To shorten the program, you could try using subroutines (with gosub) for repetative parts.

Andrew
 

hippy

Ex-Staff (retired)
If you can find common sequences for the LED's they can be put into subroutines or FOR-NEXT loops. It may also be possible to store a list of 'do this, with that' in Data Eeprom and then interpret the list as a set of instuctions on what to do, which LED to set, clear, or pulse, how long to pause for.

Ultimately you only have limited memory for holding your program and any data so for complicated patterns with no common elements you may not have any option but to move to a PICAXE with larger memory.

You may be able to define a sequence which does what you want to achieve in shorter space by using subroutines or loops.
 

eclectic

Moderator
@robnash
I've just found out what a “Cylon eye” is. :)

I think a pencil and paper are best for puzzles like this.
Write down what you want as a simple flowchart

1.The first LED (0) lights.
2.The next two both light
3.The first LED pulses
and so on.

Then, the other direction, counting downwards,

4.LED 7 lights.

5.LED 6 and 7 light.
6.LED 5 and 6 light. LED 7 pulses

and so on....

This part program might help:
Code:
;CYLON2 040609 Forum

#picaxe 20M
symbol counter = b1
symbol Eye     = b2
symbol LOWeye  = b3
symbol Higheye = b4
symbol delay   = 50  ; easier to change
symbol Ptime   = 200 ; easier to change
main:
pause 1000

cylon:
for counter = 1 to 10 ; change if required

high 0,1
pause delay
low 0,1
pause delay

for Eye = 1 to 6
 	Higheye = eye + 1
 	loweye = eye - 1

	high eye, higheye
	pause delay
	low eye, higheye ;pins = 0
	pause delay

	pulsout loweye , Ptime
	next Eye

high 7
pause delay
low 7
pause delay

for Eye = 6 to 1 step -1

	Higheye = eye - 1
	loweye = eye + 1
 
	high eye, higheye
	pause delay
	low eye, higheye ;pins = 0
	pause delay

	pulsout loweye,Ptime
	next Eye

next counter

goto main
A couple of further points:

What is the 16 pin chip, on the breadboard, next to the 20M?

A single 28X / 28X1 / 28X2 could control all 16 LED's,
as well as the switching and readadc.

e
 

rob nash

Senior Member
big thxs for for the replys,, my first post, 20 min later the psu blows in the machine,,(karma for a poor post),,
thts the reason for timely delay,,,

eclectric thxs hve to look over yr reply deeper tonight,, the 16 pin chip is a DIL 330 x 8 resistor array. an attempt at keep the final board tidy,, the down side if one pops the whole array has to come out??? agian thxs for the reply

andrew cowan (However, it can't be good for the chip,) ur right, but an interesting feature,, am guessing it wil burn the input out,, did,nt mean to go over other posts,sry, havent read all the archives yet,,
 

eclectic

Moderator
big thxs for for the replys,, my first post, 20 min later the psu blows in the machine,,(karma for a poor post),,
thts the reason for timely delay,,,

eclectric thxs hve to look over yr reply deeper tonight,, the 16 pin chip is a DIL 330 x 8 resistor array. an attempt at keep the final board tidy,, the down side if one pops the whole array has to come out??? agian thxs for the reply

andrew cowan (However, it can't be good for the chip,) ur right, but an interesting feature,, am guessing it wil burn the input out,, did,nt mean to go over other posts,sry, havent read all the archives yet,,
1. Use 3 AA cells for ALL initial development. Or even 2 AA Alkalines.
PSU blowing? In that case, keep well away from ANY "PSU" that can blow!!!

2. 8 x resistor DIL chip. Fine.
But, if one "Pops", then there's something seriously wrong somewhere!

e
 

rob nash

Senior Member
hi ecletric
thx for asking,,, i,ve taken my time wth this project well saving it for cold dark nights,,,i hve been tinkering wth the the programme u suggest iam in the middle of reading about ir as a trigger,and changing the chip
40x2 ott maybe? put the PLAN two rows 10 led triggered by ir,,,
cheers RN,,,
 

lanternfish

Senior Member
#4 Eclectic: Got to differ here. The cylon eye is basically a row of leds of which 3 are on at any one time, scanning left to right. No blinking of an led. This simplifies the whole process. So if we start with a word variable,
Code:
Pseudo code:

      W1 = %0000000000000111
main:
shiftleft:
      output W1 to leds
      pause
      shift left (%0000000000001110, etc)
      loop until W1 = %1110000000000000

shiftright:
      output W1 to leds
      pause
      shift right
      loop until W1 = %0000000000000111

then jump back to main
See how this goes?
 
Top