My first project

Randy5140

Member
Hello All!

Not totally new here as I have asked questions before, Got a lot of help and have greately appreciated it!

I am well along on my first project which is actually what got me started with picaxe.

This whole thing started for a friend. He owns several "Hawaiian Shave Ice" concessions and has had a lot of problem with his employees using too much of the flavorings

He had run across an "Instructable" article on a drink mixing machine and thought that it would be easy for me to just use the code provded to make something that would control the amounts dispensed.

I tried to explain to him that I would need to "learn" the picaxe before I could do much and so far it has been quite fun!

I have the program pretty well written,, well at least to where it works with my boards and in VSM. ( I have been using VSM for testing before building boards to save time)

I had a little problem figuring out how to count the different flavors, but finally got it working,, it will count up 10 different mixes. Problem is he has more than that number of flavors with combinations.

Like not only do I have: Lemon, Lime, Strawberry, Bannana, etc, etc, but also: Strawberry/Bannana, Lemon/Lime, etc, etc,

I am using a 40x2 and the way I am counting the mixes, controling the 8 or more solenoids to dispense and having 4 input switches, I have basically run out of pins!

Basically I am looking for ideas on ways to register more choices (flavors) and a way to display them.

Originally I planned on simply using 10 LED's counted from button pushes to display and keep track of the flavor.

In other words,, button pushed 3 times,, Led # 3 is lit, b0 carries the count, goes to flavor number that corresponds with count (b0) and dispenses the correct amount of flavor.


Now I find out I need a minimun of 22 flavors and like I said,, I have run out of pins! :)

I know you can add another picaxe chip (dont know how to do that yet though) to add more pins for more Led outputs, but with more than 10 leds up in front of the employee it would/could get rather confusing.


I also thought about using an LCD screen

The person who wrote the "Instructable" artcle used a single Nixie tube but he only had 10 drinks and that wont solve my problem plus form what I have read the voltage used for these tubes is rather high and with mostlly teenagers as employees,, who knows what could happen!

Any suggestion or ideas would be greatly appreciated!

If anyone wants to see my code let me know and I will post it.

Thanks in advance
Randy
 

russbow

Senior Member
Randy,all looks very interesting.

You will need to upload your code for all to see / pick holes in / suggest / improve. Looks like a project that will stir ( ;) ) up interest.
Leave a slot for the Gin & Tonic
 

nick12ab

Senior Member
I also thought about using an LCD screen

The person who wrote the "Instructable" artcle used a single Nixie tube but he only had 10 drinks and that wont solve my problem plus form what I have read the voltage used for these tubes is rather high and with mostlly teenagers as employees,, who knows what could happen!

Any suggestion or ideas would be greatly appreciated!
As long as the PICAXE doesn't have any 'blocking' functions in the code (serin, readtemp...) or commands that take time then you can use some 7-segment displays and multiplex them. If not, or if a large number of digits are required then a HD44780 LCD can be used. (or for 7-segment displays use SAA1064 or other driver)
 

jtcurneal

Senior Member
A CD4017 has 10 outputs only one will be active depending on the number of pulses it receives. You could control 10 LEDs using 2 output pins on your Picaxe 40X2. one pin to
reset the CD4017 and one pin to pulse the count input.

Joel
 

hippy

Ex-Staff (retired)
I would imagine an OLED display would be ideal as the clearest indicator of what has been selected and then a multiplexed keyboard, one button per flavour, multiple pushes mix flavours. So in operation; press "Lime", press "Chocolate", the display shows "Lime/Chocolate" and that's what you get. You could accept "Chocolate" twice for "Double Chocolate" etc. There may need to be a "Cancel" and/or "Go" button.

It's the sort of project where you need to decide on the aesthetics and operation and then match the code to that.
 

PaulRB

Senior Member
Like not only do I have: Lemon, Lime, Strawberry, Bannana, etc, etc, but also: Strawberry/Bannana, Lemon/Lime, etc, etc,
Randy, tell us more about the mixes. Are they "recipies" like "2 parts strawberry to one part banana to one part coconut", or are they always equal mixes eg. 50/50 or 33/33/33? If recipies, does the picaxe need to have them all programmed, or can you rely on the operator to remember them? (But now allow the operator to use more than is necessary!)

How many base flavours? If 10, there are 1,023 possible mixes if they are equal, more if the recipies are more complex.

How about this as a design: 10 buttons for the base flavours. Each button can be pressed multiple times to adjust the strength of that flavour. The mix is displayed on an LCD or OLED display (this might only need 1 pin of your picaxe). A "Clear" button will be needed for mistakes or indecisive customers. The 12th button is "Dispense". When this is pressed, the picaxe works out the percentages of each selected flavour and dispenses the total standard amount of flavour in the required ratios.

Paul
 

Randy5140

Member
To all,, thanks for the interest so far!

OK I am going to try and upload the code,, I also have a VSM file that I could email to someone if they want to run the program.
To try and answer some of the clarification questions,
I have thought about an OLED and LCD and even making one from stip Leds. Not sure what to use although something with readout like OLED or LCD would probably be best. So the user can actually see that they have the correct flavor
The system,, program whatever you want to call it will have preset mixes,, or straight flavors. There are currently 10 straight flavors. (Although my simulation is only set up for 8 right now) (My boards are capable of 16 so I can make it grow. )
Beyond the basic flavors,, strawberry, Lemon, Lime, etc, etc. There are preset mixes. Lemon/Lime,, Strawberry/Banana, etc, etc.
The mixes are preset amounts set by how long the solenoid dispensing them is on.
The bottles are pressurized with air to provide the flow to the solenoids. Thinking that way I could keep the pressure low on the valves and tubing.
As of the last time I spoke to the guy who owns the concession, 22 selections would work, at least for now.
I had the boards up and running yesterday, Flavor selection works fine, the count is held in b0 and call the correct “flavor” so it appears to be working .
I only need to display the Flavor,, Name, Number whatever..
I am currently using D.6, D.7, B.0, B.1, B.2, B.3, B.4, B.5, B.6, B.7 to turn on the LED’s.
So whatever I go to, I will have up to 10 pins to use and hopefully some spares for future expansion of the system.

OK below is the code,,
Its messy and probably not just as correct as is should be but I’m really still at the basic side.





Randy




Code:
'
'flavor mix program feb 21 2013"
' 
'
'
' setup Hardware I/O 

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'
'Solenoids (outputs) for dispensing flavors
Output C.0,C.1,C.2,C.3,D.0,D.1,D.2,D.3

	symbol solenoid0 = C.0
	symbol solenoid1 = C.1
	symbol solenoid2 = C.2
	symbol solenoid3 = C.3
	symbol solenoid4 = D.0
	symbol solenoid5 = D.1
	symbol solenoid6 = D.2
	symbol solenoid7 = D.3
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


sertxd (" reset ")  'to signal a reset has occured


'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'Lights (outputs)
	Output D.4,D.5,D.6,D.7

	symbol yellowlight = D.4 	' ok to select the mix
	symbol greenlight = D.5	      'starting the dispense process
	symbol redlight = D.6		'emergency stop the process
	symbol bluelight = D.7		'system pump start\ active


'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


'mixnumber visual output (lights an led to show the mixnumber)

	output C.6,C.7,B.0,B.1,B.2,B.3,B.4,B.5,B.6,B.7

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

	symbol mixnumber = b0


'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'Buttons (inputs)

	input A.0,A.1,A.3,A.5
	symbol selectmix = pinA.0  'PUSH BUTTON TO CHANGE FLAVOR 
	symbol startmix = pinA.1   'PUSH BUTTON TO START FLAVOR DISPENSE
	symbol stopmix = pinA.3    'EMERGENCY STOP INCASE OF OVER FLOW OR MALFUNCTION
	symbol cupswitch = pinA.5  'KEEPS DISPENSER FROM OPERATING UNLESS CUP IS INPLACE


'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'PERFORMS COUNT ON FLAVOR SELECTION

count B.0, 2000, b0

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

scanbutton: 'scan buttons


high yellowlight    ' indicates dispenser ready to have selection made. 

	if cupswitch = 1 then checkbutton  'switch under cup, if cup not in then no drink can be selected or despensed 
	if selectmix = 0 then mixnum  'turns on and off selection number indicator LED's  uses up 10 pins though,,,,
	if startmix = 0 then makeflavor 'dispense a flavor
	if stopmix = 0 then emgstop 'stop dispensing flavor
	
goto scanbutton


'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



mixnum:'turns on or off appropiriate LED

	if b0 = 0 then 
	high C.6
	low C.7,B.0,B.1,B.2,B.3,B.4,B.5,B.6,B.7


	elseif b0 = 1 then
	high C.7
	low C.6,B.0,B.1,B.2,B.3,B.4,B.5,B.6,B.7

	elseif b0 = 2 then
	high B.0
	low C.6,C.7,B.1,B.2,B.3,B.4,B.5,B.6,B.7

	elseif b0 = 3 then
	high B.1
	low C.6,C.7,B.0,B.2,B.3,B.4,B.5,B.6,B.7

	elseif b0 = 4 then
	high B.2
	low C.6,C.7,B.0,B.1,B.3,B.4,B.5,B.6,B.7

	elseif b0 = 5 then
	high B.3
	low C.6,C.7,B.0,B.1,B.2,B.4,B.5,B.6,B.7

	elseif b0 = 6 then
	high B.4
	low C.6,C.7,B.0,B.1,B.2,B.3,B.5,B.6,B.7

	elseif b0 = 7 then
	high B.5
	low C.6,C.7,B.0,B.1,B.2,B.3,B.4,B.6,B.7

	elseif b0 = 8 then
	high B.6
	low C.6,C.7,B.0,B.1,B.2,B.3,B.4,B.5,B.7

	elseif b0 = 9 then
	high B.7
	low C.6,C.7,B.0,B.1,B.2,B.3,B.4,B.5,B.6
	end if

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

low yellowlight
	mixnumber = mixnumber + 1
	if mixnumber > 9 then gosub mixnumber0 'LIMITS FLAVOR NUMBER SELECTION TO 10 (0 THRU 9) increase number as flavors increase
	sertxd ("mixnumber= ", #mixnumber,13,10) 'DISPLAYS FLAVOR NUMBER IN TERMINAL
	b0 = mixnumber
	checkbutton: 'loop here to wait for button to release

	if b0 = 0 then high B.7
		end if

	if selectmix = 1 then scanbutton '

	goto checkbutton


	mixnumber0: 'RESETS MIXNUM TO 0
	
	mixnumber = 0

return




'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





makeflavor: 



high greenlight   'GREEN LIGHT INDICATES DISPENSING IS RUNNING

	if mixnumber = 0 then flavor0
	if mixnumber = 1 then flavor1
	if mixnumber = 2 then flavor2
	if mixnumber = 3 then flavor3
	if mixnumber = 4 then flavor4
	if mixnumber = 5 then flavor5
	if mixnumber = 6 then flavor6
	if mixnumber = 7 then flavor7
	if mixnumber = 8 then flavor8
	if mixnumber = 9 then flavor9


goto scanbutton




'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





emgstop: ' emergency stop SHUTS EVERYTHING DOWN

sertxd (" EMERGENCY STOP CALLED ",13,10)

	high redlight
	low bluelight
	low greenlight
	low solenoid0
	low solenoid1
	low solenoid2
	low solenoid3
	low solenoid4
	low solenoid5
	low solenoid6
	low solenoid7
	b0 = 0
	high B.7
	pause 2000
	low redlight
	low C.6,C.7,B.0,B.1,B.2,B.3,B.4,B.5,B.6,B.7

goto scanbutton




'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

flavor0:    'Lemon
	'b1=19 for 1 ounce

	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid0
	for b1 = 1 to 28 '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1	
	low solenoid0
	low bluelight
	pause 2000
	low greenlight			
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

flavor1: 'LIME
	'b1=19 for 1 ounce
	low yellowlight
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid1
	for b1 = 1 to 28
	pause 250
	if stopmix = 0 then emgstop	
	next b1	
	low solenoid1
	low bluelight
	pause 2000
	low greenlight	
		
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++

flavor2:    'Cherry
	'b1=19 for 1 ounce
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid2
	for b1 = 1 to 28  '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1
	low solenoid2
	low bluelight
	pause 2000
	low greenlight	
		
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++

flavor3:    'Orange
	'b1=19 for 1 ounce
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid3
	for b1 = 1 to 28  '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1	
	low solenoid3
	low bluelight
	pause 2000
	low greenlight	
		
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++


flavor4:    'Grape
	'b1=19 for 1 ounce
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid4
	for b1 = 1 to 28  '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1
	low solenoid4
	low bluelight
	pause 2000
	low greenlight	
		
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++

flavor5:    'Bananna
	'b1=19 for 1 ounce
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid5
	for b1 = 1 to 28   '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1
	low solenoid5
	low bluelight
	pause 2000
	low greenlight		
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++


flavor6:    'strawberry
	'b1=19 for 1 ounce
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid6
	for b1 = 1 to 28  '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1
	low solenoid6
	low bluelight
	pause 2000
	low greenlight			
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++


flavor7:    'rasberry
	'b1=19 for 1 ounce
	high bluelight 'turn on pump
	high greenlight
	pause 1000 'pump to pressure
	high solenoid7
	for b1 = 1 to 28  '1.5 oz flavor
	pause 250 'keeps solenoid on to dispense flavor
	if stopmix = 0 then emgstop
	next b1
	low solenoid7
	low bluelight
	pause 2000
	low greenlight	
		
goto scanbutton

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++


flavor8:    'Lemon Lime

	high bluelight 'turn on air pump
	high greenlight
	pause 1000 'pump it up
	high solenoid0 'Lemon
	for b1 = 1 to 28  '1.5 oz flavor
	pause 250
	if stopmix = 0 then emgstop
	next b1
	low solenoid0
	pause 2000
	high solenoid1 'lime
	for b1 = 1 to 10  '.75 oz flavor
	pause 250
	if stopmix = 0 then emgstop
	next b1
	low solenoid1
	low bluelight
	pause 2000
	low greenlight
goto scanbutton
end
 
Last edited:

Randy5140

Member
Two things,, couldnt figure out how to upload the code in one of those small scrolling windows. (figured it out,, DuH,,, read instructions)

also go to thinking that I had an LCD Display around somewhere and sure enough I found it.

its appears to be a Chinese one havnt looked for a data sheet yet, but the numbers on the back are: RT162-7 WITH V24 below the first number. would that mean 24 character?

anyone know if there is anything on here about hooking up one of these to a 40x2 and possibly some get started code?
 
Last edited:

PaulRB

Senior Member
Randy, can you post a well-focussed close-up photo of each side of the lcd.

With luck its a standard format. Options for using it in your project are 1. Easy, but using a second picaxe (18m2 or 14m2) to drive the lcd and only 1 pin on the 40x2, 2. More difficult but driving it directly with the 40x2 using 6 or 7 pins and some tricky coding.


Suggest as this is your first project go for option 1. Have a look at the Techsupplies website for the interface board to connect between the 40x2 and the lcd. This board holds the second picaxe.

Also, you didn't really answer my question about "recipies"...
 

BeanieBots

Moderator
I'm with hippy. It seems an obvious choice to go with an OLED display.
You will then 'know' from the display exactly what you are getting.
Not much more code would also allow you to have primary flavours which could be mixed to give combinations. eg select one flavour then select another to give a combination.
It would even be possible to devise a menu system (selectable by eg holding down a button at power up) that would allow the addtion/removal of flavours without the need to re-program.

Add a display, it will offer much more scope and be ultimately easyier and more flexible to program in the long run.
 

hippy

Ex-Staff (retired)
anyone know if there is anything on here about hooking up one of these to a 40x2 and possibly some get started code?
Manual 3 has examples for interfacing LCD and there's been plenty of discussion on the forum but you are probably better off considering an AXE133Y.

To find how many characters, connect just the LCD's power (5V) and the contrast pin to 0V; most should show black blobs on the top row in each character position.
 

Randy5140

Member
Paul,

trying answer to your question about flavors.

There are 10 straight flavors, so that is 10 choices (or possible mixes)

There are 12 combinations, so that is 12 more choices. (or possible mixes)

This is a total of 22 Flavors

The mixes are preset in the program code as to how much of each flavor is dispensed. (take a look at the code and you can see the preset mixes I think #8 or #9 are two flavor mixes.

the mixes can be 1, 2, 3 or however many flavors needed by modifing the code.

I havent gotten to the adjustemet of time on for the solenoids yet for each flavor as some measuring will need to be done when I get the "machine" built.

Now that I have some "working" code I plan to start building the "machine" in the next week or so.

I am also trying to decide on a "theme" for the machine as his (my friend) 's booth is kind of retro/Hawaiian for lack of a better term.

He has 6 of them all in trailers with decorations that flip up or attach to the outside when setup.

He also is a radio nut,,, not building them,, nothing electronic at all,, just a collector, he has a garage full of them so I am kind of leaning tward something like one of the Old floor model radios.

I have done a few sketches of one in CAD with a grill on front. lots of knobs and such.
 

hippy

Ex-Staff (retired)
There are 10 straight flavors ... There are 12 combinations ... This is a total of 22 Flavors
Got it! That could be implemented as 22 buttons on a 4x6 matrix with two spare buttons, or 5x5 with three spare, and both would use just 10 I/O lines.
 

Randy5140

Member
Hippy,

OK,, I looked for the AXE133y but couldnt find it, I did find an AXE033Y and yes that would do the trick.

I have several 40x2's is there a schematic anywhere that shows how I could make use of one of them to so the job as an addon to the original 40x2?

I looked for a schemaic on the AXE033Y but so far havent found one.

I dont have a problem with the price, I just like making my own boards. I have done some looking but I cannot find anything on connecting two 40x2's together.

I am guessing,, that I could use one of them to drive the LCD and only one pin from the original (master) 40x2, at least from what I have looked at.

also the additional 40x2 would up the spare pin count for other uses, like additional lights or sounds,,

this thing will normally be used in a carnaval or fair location so lights and sounds would be a great addition! :)

I know,, I know,, making it more complicated,, but thats just me,, :)
 

Randy5140

Member
Hippy,

Hey,, I will get an AXE133Y ordered tomorrow,, looks like it will work great! Plus it frees up a bunch of outputs on the 40x2 for other options!

thanks to all for their input and ideas!


if anyone wants to use my code for anything feel free,, drop me a note later (give me a week or two to get the LCD up and running) and I will be happy to post or email the finished code.
 

Paix

Senior Member
Possibility that V24 refers to CCITT V24 (akin to RS232) interface standard (voltages, as opposed to connection). Probably a red herring, but a historical note, nonetheless). :)
 
Top