# New Picaxe Chip due out



## fritz42_male (May 5, 2009)

For all of you Picaxe enthusiasts out there there is a new Picaxe chip due out - the 18M2

With multi-tasking onboard, this looks interesting to say the least!

http://www.microzed.com.au/PDF/picaxe18m2.pdf


----------



## psyko99 (Jan 11, 2008)

This looks promising. Being a Picaxe noob, I'm still reading everything I can.

Thanks for sharing.


----------



## HauntNH (May 17, 2010)

is there a good place to get some haunt code to learn from for these chips? maybe someone would be willing to share


----------



## hpropman (Jul 27, 2008)

HauntNH said:


> is there a good place to get some haunt code to learn from for these chips? maybe someone would be willing to share


what code are you looking for:

I have posted some of my code on here already. I have code for random head movement, fading eyes, prop controller etc.. I have started to write a book on the picaxe and the first installment is available on my website. I will update it as write every few chapters.


----------



## fritz42_male (May 5, 2009)

Same here - I posted random led eye flashing code for the Picaxe 14M chip plus a delay/duration timer that I use to drive a smoke machine.


----------



## HauntNH (May 17, 2010)

Well I have some programming knowledge, and I was looking at the editor and simulating some of the code I was writing. But I was wondering how others have done theirs, ex... what kind of delays are you using, and how are you triggering them.... Do you use one chip per prop, or do you try to randomize the sequence of multiple props with one chip and if you randomize them how are you doing that are you seeding the random function (because if you have used it you know the random function is not really random) etc... so nothing really specific, more how are you using/programming the chip, vs how I would do it.


----------



## HauntNH (May 17, 2010)

and btw hpropman your book is why I started looking at these chips


----------



## fritz42_male (May 5, 2009)

HauntNH said:


> Well I have some programming knowledge, and I was looking at the editor and simulating some of the code I was writing. But I was wondering how others have done theirs, ex... what kind of delays are you using, and how are you triggering them.... Do you use one chip per prop, or do you try to randomize the sequence of multiple props with one chip and if you randomize them how are you doing that are you seeding the random function (because if you have used it you know the random function is not really random) etc... so nothing really specific, more how are you using/programming the chip, vs how I would do it.


Here is the code for the delay/duration timer. It is non-triggered but easily changeable.

symbol delay=1
symbol duration=2

begin:

b2 = 0
Do
ReadAdc delay, b1
Pause 100
b2 = b2 + 1
Loop Until b2 >= b1

high 0
high 4

b3 = 0
Do
ReadAdc duration, b4
Pause 100
b3 = b3 + 1
Loop Until b3 >= b4

low 0
low 4

goto begin


----------



## fritz42_male (May 5, 2009)

And here is the code for the Random LED eyes - this is for the 14M on the Axe117 board. Nice & simple, the LEDs connect to the buffered outputs. If I want a fading effect on the eyes, I put an electrolytic capacitor of various values across them. I use 6 pairs of eyes at the end of Cat5 cable. Each pair is mounted on a little piece of hardboard with screw terminals. The picaxe board is mounted inside a project box and I use speaker terminals for quick attach/detach.


symbol led0 = 0
symbol led1 = 1
symbol led2 = 2
symbol led3 = 3
symbol led4 = 4
symbol led5 = 5

main:
startup:
high led0
high led1
high led2
high led3
high led4
high led5
pause 2000
low led0
low led1
low led2
low led3
low led4
low led5

goto flash

flash:
Random w0
Random w1
w2 = w0 / 80
w3 = w1 / 11
if w3 < 1000 then: high led0
pause w2
low led0
elseif w3 < 2000 then: high led1
pause w2
low led1
elseif w3 < 3000 then: high led2
pause w2
low led2
elseif w3 < 4000 then: high led3
pause w2
low led3
elseif w3 < 5000 then: high led4
pause w2
low led4
elseif w3 < 6000 then: high led5
pause w2
low led5



endif
goto flash


----------



## fritz42_male (May 5, 2009)

PS
I plagiarise most of my code - it's easier so thanks to whoever wrote the original stuff.

As for being pseudo random - who cares? lol


----------



## HauntNH (May 17, 2010)

Thanks for the code. looks simular to how I was doing some of mine, 


fritz42_male said:


> As for being pseudo random - who cares? lol


as for random my problem was because I was trying to control more then one prop with one chip....I tried to watch an input for a high or a random number of loops through the main routine and then went to a sub routine which then chose 2 random numbers one which decided how meny times to loop and the other one fired a prop, then choose another random number to fire another prop.. BUT what happened is every time I ran the sub routiune it was generating the same random number, and always running the same 3 props in the same sequence.

I guess using one chip as the brains wont be as easy as I thought.


----------



## HauntNH (May 17, 2010)

oh BTW thanks for the idea of the caps for fade rates...


----------



## fritz42_male (May 5, 2009)

I picked that one up from watching an LED MR16 globe fading slowly - I thought ahhhhhh!

Simple & it works well.


----------



## hpropman (Jul 27, 2008)

HauntNH said:


> and btw hpropman your book is why I started looking at these chips


Glad to hear that my book is being put to good use. I have been away for a few days but I will post some code samples for you as soon as I can. I have to go and finishing taking care of the camping stuff now.


----------

