"Chum Dispenser" solution with picaxe - advice needed by noob

satrapus

Member
Hi folks.

First of all let me point out that I have no experience with picaxe, some very basic electronics knowledge and a background in software engineering.

I would very much appreciate if someone could answer my questions posed below.

The system is powered by a 12V car battery.
Inputs are (Main 3 position switch, timer and ir sensor)
Outputs are (Piezo alarm, dc motor and ir led)
The timer knob controls the interval at which chum is dispensed overboard (1 to 60 seconds).
The side of the control box has a motion sensor that registers when a piece of chum is chucked overboard.
Once triggered, the timer is reset.
If the sensor doesn't register anything in 60 seconds it sounds of an audio alarm (piezo buzzer) that indicates the chum tray is empty.
A 12v 35rpm dc motor contained within the control box draws 0.2 - 0.8 A.

Questions:
My main concern is the fact that I'm using a 12v power supply and that all of my 3 outputs also run off 12v (piezo, motor and motion sensor).
Would I need to use relays to control these 12v driven devices with the 18M2?

I am considering the PICAXE-18M2 as a candidate for the job. This should make a much simpler, more reliable and elegant solution to the old school one show in the video (you can't see the internals but there is no micro controller, just a whole bunch of 555s etc). Is this chip the right choice given my inputs and outputs?

Thanks in advance for any advice or suggestions.
 
Last edited:

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

I would expect the PICAXE-18M2 to be up to the task. I would recommend Programming Editor 6 and my preference would be to program in PICAXE Basic rather than flowcharts given your background in software engineering.
 

geoff07

Senior Member
You should be able to control the outputs with logic level mosfets, which might be simpler/smaller/cheaper than relays. You will need a regulated supply for the Picaxe (common ground with the 12v), and to make sure that 12v doesn't get to the inputs.

The main factor in choosing the chip is whether it has enough inputs and outputs, and then price (the ones with more i/o cost more). Otherwise I would expect almost any chip to do what you want as there aren't any particularly special requirements.
 

satrapus

Member
Thanks for the advice fellas!

Just one more question :)
How does picaxe compare to arduino?
I was told it would be easier for me implement a solution using picaxe.

ATB
 

westaust55

Moderator
Thanks for the advice fellas!

Just one more question :)
How does picaxe compare to arduino?
I was told it would be easier for me implement a solution using picaxe.

ATB
Firstly please note that this forum is provided by Revolution Education - the creators of the PICAXE.
Topics should be related to PICAXE and not other microcontrollers.
See:http://www.picaxeforum.co.uk/showthread.php?7679-Read-Me-First!

In response to your question (and noting your software background),
Many would find the BASIC programming environment easier earlier than programming in other languages.

The PICAXE chips use interpreted BASIC which will execute slower that code compiled to machine code but for your application speed is not foreseen to be a significant requirement and a PICAXE running at the slower default speed should suffice.

Your IO list indicates 5 inputs (4digital and 1 analogue) and 3 outputs (use MOSFETs as already mentioned).
The 18M2 can do this with significant spare IO and even a smaller 14M2 is up to the task.
http://www.picaxe.com/Site_Resources/Media/Site_1/pinout/pinout14m2.jpg
 
Last edited:

geoff07

Senior Member
I think Westy meant 'easier' rather than 'earlier', and most on this forum would agree.

Arduinos are usually programmed in C, or so I understand. Picaxe Basic isn't 'basic' at all, and can do pretty much everything that you can do in C, but with less complexity and, indeed, less speed, though that rarely matters. For the kind of things that Picaxes are used for i.e. controlling hardware, not solving maths puzzles or high end graphics, they are hard to beat. For development speed i.e. time from zero to working, they are impossible to beat in my experience.
 

tony_g

Senior Member
Thanks for the advice fellas!

Just one more question :)
How does picaxe compare to arduino?
I was told it would be easier for me implement a solution using picaxe.

ATB
the picaxe system as a whole is very easy to get to grips with,i had no prior experience before jumping in and now can have fun creating lots of great little things that amuse me lol.

the only thing you have to remember is theres no such thing as a stupid question, if your not sure about something just ask on here and you will get a wealth of help/responses as long as you show you are trying, some people unfortunately dont and just expect it done for them and wonder why they get minimal responses.




tony
 

hippy

Technical Support
Staff member
I was told it would be easier for me implement a solution using picaxe.
That's likely true. PICAXE Basic has a fairly clean and uncluttered syntax which makes it easy to start working with and has a pretty gentle learning curve. PE6 includes a simulation capability which means you can get familiar with the PICAXE, even get your project software working, without having to invest in hardware first.

One of the best PICAXE resources is this forum; or more so its members.
 

SAborn

Senior Member
Here in Oz "chum" is a brand of dog food so i expected a dog feeded, but it would seem in the UK "chum" is a fish bait feeder.
 

westaust55

Moderator
Here in Oz "chum" is a brand of dog food so i expected a dog feeded, but it would seem in the UK "chum" is a fish bait feeder.
True SAborn - had the same initial thought - a dog feeder :)
Here in the west of Oz at least, "burley" in various forms is the mix used to help attract the fish.
 

satrapus

Member
This chum feeder will be used for offshore big game fishing (my main target species is blue fin tuna)

Here's my first stupid question:
My main control switch is a 3 way on off on (Continuous/OFF/Timed).
I take it this switch will use up 2 input pins as the input for a switch can only be hi or low?
 

Goeytex

Senior Member
Here's my first stupid question:
My main control switch is a 3 way on off on (Continuous/OFF/Timed).
I take it this switch will use up 2 input pins as the input for a switch can only be hi or low?
There are no stupid questions. (Well, there really are, but we like to say that anyway), but this is not one of them.

Actually the switch could be wired through resistors to a single ADC input. IF the value is 0 - 50 then OFF. IF 100 to 200 then Timed, IF > 200 then continuous.
 

goom

Senior Member
This chum feeder will be used for offshore big game fishing (my main target species is blue fin tuna)

Here's my first stupid question:
My main control switch is a 3 way on off on (Continuous/OFF/Timed).
I take it this switch will use up 2 input pins as the input for a switch can only be hi or low?
Not necessarily, but you certainly could use 2 inputs. The Picaxe is capable of reading analog voltages, so if you arranged your switch so that it provided 0, 2.5v and 5V to an input, then only one input could be used to determine which of the 3 states was selected. See the READADC command.
Remember, no such thing as a stupid question, just stupid answers.
 

satrapus

Member
Great.

And what's the story with symbols in all the picaxe examples?

Say here:

symbol door_switch = pinc.0
main:
if pinc.0 = 1 then door_shut
; why not use if door_switch = 1 then door_shut
; it seems the symbol otherwise serves no purpose ?
 

goom

Senior Member
Symbols are simply used as a programming aid. It makes it easier to understand the code for yourself when developing, and particularly when modifying and/or troubleshooting. It also helps a lot if you ask others to review your code. The use of symbols does not change the size of the code when actually programming the Picaxe, so use liberally with no downside.

If you used a potentiometer as the input for the chum feed rate, you could then have infinitely variable control.
 

AllyCat

Senior Member
Hi,

; why not use if door_switch = 1 then door_shut
Indeed. But do beware that you may need quite a rigorous "naming strategy". Note the (non-optional) use of "pin" and that one "name" is a label in the following example:

Code:
SYMBOL door_switch = [B]pin[/B]c.1
SYMBOL door_motor = c.2
	IF door_switch = 1 THEN [B]{GOTO}[/B] door_shut
;.......
door_shut:
	HIGH door_motor
And thanks SAborn, I also was confused because AFAIK CHUM is (still) a dogfood brand also in the UK.

Cheers, Alan.
 
Last edited:

RexLan

Senior Member
Why would that indicate a bad day?.

Since the vast majority of new posters do not read the Read-Me-First, a gentle reminder from time to time seems a good idea.
Rhetorical.

Guy asked a simple and legitimate question and it was his 4th post. Maybe it was a "stupid question then?

How do you know he has not read the Read-Me-First or is that an assumption? I haven't until now and it sounds like you have not either.

Point was / is that it was completely unnecessary and it was also rude IMHO; politely said as "are we having a bad day" .. now we have it said directly.

I found it distasteful enough to say something to an otherwise significant contributor.

I'm out.
 

lbenson

Senior Member
What the device is emitting is called chum in the U.S., though the chum that I'm familiar with (fishing for bluefish) is a slurry, thrown out by the cupfull (tunas are a bit bigger).

What causes the half-sardines to stick to the upward-going roller?
 

Armp

Senior Member
Rhetorical.

Guy asked a simple and legitimate question and it was his 4th post. Maybe it was a "stupid question then?

How do you know he has not read the Read-Me-First or is that an assumption? I haven't until now and it sounds like you have not either.

Point was / is that it was completely unnecessary and it was also rude IMHO; politely said as "are we having a bad day" .. now we have it said directly.

I found it distasteful enough to say something to an otherwise significant contributor.

I'm out.
I think this forum is entering the "Final Phase". Last one out please turn off the lights!
 

satrapus

Member
What the device is emitting is called chum in the U.S., though the chum that I'm familiar with (fishing for bluefish) is a slurry, thrown out by the cupfull (tunas are a bit bigger).

What causes the half-sardines to stick to the upward-going roller?
Barbless hooks arranged in a diagonal pattern on the rubber belt. They grab hold of the sardine chunks and flip them overboard.
I tend to chop each sardine into at least 4 pieces as the idea is to drive the bft nuts rather than to fill their bellies.
A lot of charter boats also use a secondary machine that finely grind sardines up. The mush of blood, guts n scales creates
a nice slick in the current. All a bit ot :)
 

Dartmoor

Member
Hi folks.

First of all let me point out that I have no experience with picaxe, some very basic electronics knowledge and a background in software engineering.

I would very much appreciate if someone could answer my questions posed below.

Here's a video of what I'd like to build :
[video=youtube_share;0QksFPaxV00]http://youtu.be/0QksFPaxV00[/video]

The system is powered by a 12V car battery.
Inputs are (Main 3 position switch, timer potentiometer knob and photo modulator)
Outputs are (Piezo alarm, dc motor and ir led)
The timer knob controls the interval at which chum is dispensed overboard (1 to 60 seconds).
The side of the control box has a motion sensor (ir diode and photo modulator) that registers when a piece of chum is chucked overboard.
Once triggered, the timer is reset.
If the sensor doesn't register anything in 60 seconds it sounds of an audio alarm (piezo buzzer) that indicates the chum tray is empty.
A 12v 35rpm dc motor contained within the control box draws 0.2 - 0.8 A.

Questions:
My main concern is the fact that I'm using a 12v power supply and that all of my 3 outputs also run off 12v (piezo, motor and motion sensor).
Would I need to use relays to control these 12v driven devices with the 18M2?

I am considering the PICAXE-18M2 as a candidate for the job. This should make a much simpler, more reliable and elegant solution to the old school one show in the video (you can't see the internals but there is no micro controller, just a whole bunch of 555s etc). Is this chip the right choice given my inputs and outputs?

Is the PicAxeEditor6 a suitable development environment or would Proteus 8 Pro be better?

Should I code or flowchart the solution?

Thanks in advance for any advice or suggestions.
I am no expert but my views are:
No, you do not need to use relays but you could. You can use FET's to drive the outputs, together with a 5v regulator to supply the Picaxe from 12v.

The main 3-position switch could be just one input? - "Power to Picaxe" / "Off" / "Power to picaxe & an input pin."
The Picaxe can then decide on continuous or timed mode based on whether the input is high or low?

The 18M2 should be ideal.
The CHI035 circuit board includes 4 FET's and is designed for a 78L05 (or similar) voltage regulator. Just needs the regulator & Picaxe (& optional terminals). No need to design a circuit board?

PicAxeEditor6 would be fine. My preference would be the flowchart, because it is so simple (like me?). I know the experts prefer 'basic' but your project is pure logic plus one timer, so the flowchart is ideal.

The timer potentiometer could be read by the DAC input, or could be a binary-coded rotary switch which is connected to say 3 inputs (instead of the 1) giving up to 8 pre-set speeds/times?

Remember that you can have more than one loop. That means, for example, that you can read the inputs continuously in one loop without being affected by wait times etc in another loop. It avoids the need for interrupts, of which I think there is only one available on the 18M2?

You could also easily add a remote control? Probably simplest is a keyfob "car alarm" type with one or two buttons? These are really cheap now, especially from China.

Hope that helps!
 

satrapus

Member
Thank you Dartmoor, very helpful advice indeed!
I've ordered a CHI035, 18M2 and a usb transfer cable.
I was going to use a 10K pot as I want to have fine control over the timing interval (from 1 to 60sec).
When you mention multiple loops are you referring to the chips ability to run tasks in parallel?
I already thought that this would be more elegant than using interrupts.

ATB
 

Dartmoor

Member
Yes, by multiple loops I meant parallel tasks.
The pot should work fine and be straightfoward to configure (I have never actually tried it yet but it looks easy enough).

Good luck - should be a good starter project!
 

satrapus

Member
So while I'm waiting for the hardware to arrive I decided to write a program running 4 simultaneous tasks to simulate my system.

I am attempting to use the Simulation window in PICAXE editor 6 for testing purposes.
The plan was to click on pins thus changing their value.

When I click on pin c1 during program execution it turns yellow and the debugger shows pin.c1 as having decimal value of 1.

I am having trouble setting pin states in the simulator the same way via code.
If I execute pinc.1 = 1 pinc.1 value remains 0 in the debugger?
if I do high c1 the simulator changes its color of pin c1 to blue???

What command will set a pin state to yellow and what do the different colors represent?

Thanks
 
Last edited:

AllyCat

Senior Member
Hi,

It depends whether each pin is set as an input or an output, a pin can't be both at (exactly) the same time !

It's a hazard that PIXCaxe Basic "automatically" sets the "data direction" with certain commands, for example HIGH (or LOW) C.1 sets the pin as an output. The simulator allows you to control any inputs and the program to control its outputs.

If I execute pinc.1 = 1
PINC.1 = 1 doesn't fail a syntax check, but I don't know what it would/should do. Normally the syntax is IF pinc.1 = 1 THEN ... which assumes that c.1 is an input.

The use of the "pin" prefix is rather a "legacy" issue, because the Program Editor/Compiler always converts "c.1" into a number (which happens to be 1 for the c port). So a command such as IF c.1 = 1 THEN ... is always true (because 1 = 1), therefore "pinc.1" is necessary to specify that the program text is referring to reading an input pin.

Cheers, Alan.
 

satrapus

Member
Hi Alen,
if you find the time have a peek at this code:

; IC : PICAXE-18M2

; INPUTS
symbol main_switch = c.0 ; main 3 position switch
symbol timer_pot = c.1 ; timer potentiometer knob
symbol ir_photo_mod = c.2 ; ir photo modulator

; OUTPUTS
symbol ir_emitter = b.0 ; ir led
symbol dc_motor = b.1 ; 12v dc motor
symbol piezo = b.2 ; 12v piezo buzzer


start0:
;initialize input pins
low main_switch
low timer_pot
low ir_photo_mod

;initialize output pins
high dc_motor;
high piezo;


start1:
how can I simply code a check that looks at main_switch value
and depending on it turns on motor?
if high b.0 sets that pin to be used for output how do I activate that output?
 

AllyCat

Senior Member
Hi,

All (M2) pins are set as inputs by default. The first time that a HIGH or LOW command refers to a pin, that pin is automatically set to be an output (1 or 0 depending on the command).

Thus, you do not need to "initialise" pins as inputs. Generally, you will refer to input pins in an "IF" statement, so the symbol declarations should use the pinC.x format. The Start: labels initialise mult-tasking and you're not (yet) doing anything which requires parallel tasks, so Keep It SimpleS for now.

So your code (between [ code ] [ /code ] tags) might be:

Code:
#picaxe 18m2

; INPUTS
symbol main_switch = pinc.0 	; main 3 position switch
symbol timer_pot = c.1 			; timer potentiometer knob
symbol ir_photo_mod = pinc.2 	; ir photo modulator
symbol timer_value = b8		; Value read from pot

; OUTPUTS
symbol ir_emitter = b.0 		; ir led
symbol dc_motor = b.1 			; 12v dc motor
symbol piezo = b.2 				; 12v piezo buzzer

init:						;initialize output pins
	low dc_motor;
	low piezo;
main:
do
	if main_switch = 1 then			; Assuming the switch pulls up (to supply) with a pull-down resistor
		high dc_motor				; Activate motor pin (to drive relay or transistor)
	else
		low dc_motor				; Switch motor driver off
	endif
	readadc timer_pot,timer_value
	if timer_value > 10 then
;		do something
	endif
loop
end
See Manual 2 for more details on the commands and Manual 3 for typical interface circuits (for motor and switch, etc.).

Cheers, Alan.
 

satrapus

Member
Thank you Alan.
I have a lot of reading up to do :)
I wanted to get the basic logic down with parallel tasks as I think it's either that or using interrupts.
Not as easy as I thought - I just found out that pause is not accurate in parallel tasks.
 
Last edited:

SAborn

Senior Member
Its really a very basic project to make it work, and i think its become complicated by your lack of making a start and expecting others to direct you.

I see it as a common problem with the forum often, where often things get blown out of reality due to tooooooooooo many questions asked and no real testing done on your behalf.

It would seem you want answers before you make a start, but once you make a start you will find the answers you keep asking for.

Over all untill you get off your butt and make a start, all we are doing is making the project more complicated.
 

SAborn

Senior Member
I dont think you were just kidding and want others to do your homework for you.

Have a go and we will help, but im not prepared to do the work for you, it is a easy task and i could do it in a evening, but so could yourself if you make a start and use the forum to help you.

Its your project and not mine so best you lead the way.

Like many here we often spend a lot of our time helping people on and off forum for free with projects, but personally i only give time to those who take the time to make a start and request help along the way, i dont do A to Z projects for others who make no attempt to work a few things out for themselves.
 

satrapus

Member
I dont think you were just kidding and want others to do your homework for you.

Have a go and we will help, but im not prepared to do the work for you, it is a easy task and i could do it in a evening, but so could yourself if you make a start and use the forum to help you.

Its your project and not mine so best you lead the way.

Like many here we often spend a lot of our time helping people on and off forum for free with projects, but personally i only give time to those who take the time to make a start and request help along the way, i dont do A to Z projects for others who make no attempt to work a few things out for themselves.
Well then you're just plain wrong as I didn't ask for anyone to code the project for me at any point.
The fact that my failed to see the sarcasm in my earlier reply to you is not my problem.
Personally I think the icon on the end was a giveaway but that's just me.

I was told that parallel tasking would be a nice solution in order to avoid interrupts.
Apparently that will not work as the pause command is not accurate when used in parallel tasks.
As timing is pretty much the basis of my project I think seeking advice on the matter is valid and not piss taking.
 

hippy

Technical Support
Staff member
Before gauntlets are thrown and it becomes pistols at dawn just a gentle reminder that forum policy is to keep things civil and not let issues run out of control.
 

rossko57

Senior Member
I can't see why you'd want interrupts or multitasking; the timing here is the 1-60 seconds league isn't it? I would think simple procedural code, string of sausages stye, would do the job. Especially if you exploit the convenient M2 elapsed seconds counter. Check, this sensor, do that action; check the timer, do this action; etc. ; loop to start.
 

Dartmoor

Member
Especially if you exploit the convenient M2 elapsed seconds counter. Check, this sensor, do that action; check the timer, do this action; etc. ; loop to start.
Thanks Rossko! I think I have learnt something new here too! I will have a play.

I only ever mentioned the multitasking because it took me a while to find a way to respond instantly to inputs whilst performing "wait/pause", which I thought might be useful on this project.
I apologise if it was wrong / unnecessary / confusing.

Hopefully all the toys have now been thrown from the prams & we can play & learn together?
I do enjoy reading this forum regularly and have learned a lot from it.
 

rossko57

Senior Member
For this kind of machine, you don't need 'instant' responses. If it takes 50mS to respond to a button, or if it doesn't read the rate-of-feed doodah until the next feed event - do you care?
You would want to avoid locking things up in a pause for twenty seconds of course, so don't do that. Run round in a loop doing everything else and checking the independant timer, until twenty seconds have elapsed.
 
Top