I have a problem with a school projekt. We beginning at school with the Vellemann Vm110n for ca. 2 month.
I have programmed a little cocktail maschine but i have no idea as i go forward in my homework.
I work with Borland 6 Builder C++
The vm110n Card should switch these three outputs for the time.
I should to program it that at a Digital Input came a signal for the glass stand in the right position for the cocktail.
If i remove the glass in the time that the Card give outputs (ingredients) the programm switches the outputs off for the time that the glass is away. Is the glass stand again in the right position (the Card have an Input (ReadDigitalChannel(1))) the rest of the seconds pass of until the cocktail is finished.
i have no idea how to program it.
Thanks for yout help and i hope you understand my english and my problem
What you are looking for, from a software point of view, is a “state machine”.
The overall system starts in “mode idle”. From the code you posted I assume that the mere presence of a glass, detected by digital channel 1, kicks off the whole thing, so let’s say when the glass is detected, the state machine enters “mode mixing”.
Mode mixing has several “timed” submodes, one for each ingredients to pour, one for each action to perform (like stirring or shaking). The timer routine will check if the glass is still present and count down each submode.
If the glass is removed, the state machine turns off all outputs and stops advancing. But it stays in the overall mode “mixing”. So if the glass is put back, it will resume where the process was left off.
Only if the state machine finishes all the submodes, it will wait for the glass to be removed before returning to “state idle”. Drink, rinse glass and repeat.
[quote=“MostlyHarmless”].
Mode mixing has several “timed” submodes, one for each ingredients to pour, one for each action to perform (like stirring or shaking). The timer routine will check if the glass is still present and count down each submode.
If the glass is removed, the state machine turns off all outputs and stops advancing. But it stays in the overall mode “mixing”. So if the glass is put back, it will resume where the process was left off.
Only if the state machine finishes all the submodes, it will wait for the glass to be removed before returning to “state idle”. Drink, rinse glass and repeat.[/quote]
Yes, at the moment the glas stand at the Sensor and the sensor give a signal at Digital Input 1.
I klick at my programm on a button and the mix process beginn.
Now i must modification the mixer to Controll permanently the input during the “mix” Programm is running. And the “pause” function
as you have described above
Can you wrote a litte programm or a help where to start. If i need a loop or…
Sorry, I stopped doing other peoples “homework” some 35 years ago.
Besides, I don’t think your assignemt was to find someone on the internet to write the code for you.
What you need is not a loop. What you have (so far) is an event driven program. The click-button event is apparently setting some global variable. The timer event is supposed to drive the “state machine”. You will need a few more global variables for counters and states. Inside the timer, you will then have if/else and case structures, that express the mixing logic.