
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
> Hallo again, > Okay this time in english. > > Transport beld goes 40 meters/minute (average speed, it's adustable to the proces) > packetlenght = 18 cm > max 140 packets per minute (Between 110...140 packets/minute depending on the proces) > > So, with the maximum speed of 40 mtr/min = 66 cm/sec the packages are 28 cm seperated from each other. The space between the barcodescanner and the cilinder is aprox. 70 cm. So lets say that between the scanner and the cilinder 3 package fit. > > I need to know how to program this problem. > example: > > #begin > wait scanner = on > period = timer + speed (depending on beldspeed) > > #cilinder > if period > timer then goto cilinder > cilinder = on > pause 2 > cilinder = off > goto begin > > In this example one package will be trow out. but if package 1,2,4,6,7 must be trow out, this little program will not work. I'll have constantly poll the barcodescanner, and add a time to this trigger. And there is my problem, when I'm waiting for the timer to activate the proces, I cannot poll my triggerinput. first congratulation to this posting it contents most of the information needed to suggest a solution to this problem if you are waiting with "pause" you can do nothing else but wait as the name of the Basic-order says "pause" = make a brake (and have no kitkat or do anything else) if you are not using interrupts to control time-relevant things the other method is to check EVERYTHING with a Check-frequency that is two or three times higher than the shortest Signal that must be controlled now one solution is not to use the basic-order pause at all the c-control-System has an internal FREE-RUNNING timer free-running means you can do what ever you want THIS timer is counting up one by one every 20ms know the technique to have main-loop that is running in circels ALL the time in all situations run the following easy example-programm in the simulator: define TimerVar word define ScannerSignal port[1] TimerVar = timer 'store actual value of 20ms-Timer #Loop if ScannerSignal = ON then print "Scanner is on" if Timer - TimerVar > 200 then gosub DoSomething goto Loop #DoSomeThing print Timer - TimerVar print "actual Timervalue=",Timer print "stored Timervalue=",TimerVar print "Difference of the Timervalues=",Timer - TimerVar print Timer - TimerVar TimerVar = Timer return The Outputwindow shows something like that: 206 actual Timervalue= -3453 stored Timervalue= -3665 Difference of the Timervalues= 224 230 205 actual Timervalue= -24943 stored Timervalue= -25155 Difference of the Timervalues= 224 229 the serial output takes some time until it is done as you can see this timer is really free running because the difference timer - timervar is growing while the program is working down the subroutine "DoSomeThing" if packet 1,2 6,7,8 etc. should be pushed off calculating the shorter timeperiods for the next push would result in a lot of "if then" conditions it is easier to see each push as its own thing that is independent from the other pushes for that you have to use seperate "timers" for each push but that's no problem as you can see in the sourcecode following now your real program should have the following structure define ScannerSignal port[1] define CylinderPushing port[2] define BadSCanTimerValue1 word[1] define BadSCanTimerValue2 word[2] define BadSCanTimerValue3 word[3] define BadSCanTimerValue4 word[4] define StartPushCylinderTimerValue word[5] define CalledFirstTime word[6] define TimePeriodFromScannerToCylinder 100 'this value must be tuned by experiment define CylinderPushingPeriod 40 'this value must be tuned by experiment BadSCanTimerValue1 = 0 'initialize with zero to make clear "no BadScan signals received variables are free to store timervalues" BadSCanTimerValue2 = 0 BadSCanTimerValue3 = 0 BadSCanTimerValue4 = 0 StartPushCylinderTimerValue = 0 CalledFirstTime = 0 #CheckingLoop if ScannerSignal = ON then gosub StartTimer if ScannerSignal = OFF AND CalledFirstTime = 1 then CalledFirstTime = 0 'if BadRead-Signal is over reset CalledFirstTime if BadScanTimerValue1 <> 0 then gosub CheckBadScanTimer1 if BadScanTimerValue2 <> 0 then gosub CheckBadScanTimer2 if BadScanTimerValue3 <> 0 then gosub CheckBadScanTimer3 if BadScanTimerValue4 <> 0 then gosub CheckBadScanTimer4 if StartPushCylinderTimerValue <> 0 then gosub CheckCylinderPushingTimer goto CheckingLoop #StartTimer if CalledFirstTime = 1 then return 'StartTimer is called again after detecting a BadScan-Impuls so do nothing CalledFirstTime = 1 print "StartTimer" if BadScanTimerValue1 = 0 then goto StartTimer1 if BadScanTimerValue2 = 0 then goto StartTimer2 if BadScanTimerValue3 = 0 then goto StartTimer3 if BadScanTimerValue4 = 0 then goto StartTimer4 #StartTimer1 print "Timer1 started" BadScanTimerValue1 = timer if BadScanTimerValue1 = 0 then BadScanTimerValue1 = 1 'the value "0" is for saying the program this timer is not in use 'the systemtimer "timer" runs from -32768 to +32768 so the value "0" 'could be returned from "timer" then this packet would'nt be pushed of 'so its neccessary to make shure that the timervalues stored for '"timing a push" must be nonzero (<>0) return 'from StartTimer #StartTimer2 print "Timer2 started" BadScanTimerValue2 = timer if BadScanTimerValue2 = 0 then BadScanTimerValue2 = 1 return 'from StartTimer #StartTimer3 print "Timer3 started" BadScanTimerValue3 = timer if BadScanTimerValue3 = 0 then BadScanTimerValue3 = 1 return 'from StartTimer #StartTimer4 print "Timer4 started" BadScanTimerValue4 = timer if BadScanTimerValue4 = 0 then BadScanTimerValue4 = 1 return 'from StartTimer #CheckBadScanTimer1 if Timer - BadScanTimerValue1 > TimePeriodFromScannerToCylinder then goto StopBadScanTimer1 return 'from CheckBadScanTimer1 without doing anything because TimePeriodFromScannerToCylinder was not over #CheckBadScanTimer2 if Timer - BadScanTimerValue2 > TimePeriodFromScannerToCylinder then goto StopBadScanTimer2 return #CheckBadScanTimer3 if Timer - BadScanTimerValue3 > TimePeriodFromScannerToCylinder then goto StopBadScanTimer3 return #CheckBadScanTimer4 if Timer - BadScanTimerValue4 > TimePeriodFromScannerToCylinder then goto StopBadScanTimer4 return #StopBadScanTimer1 BadScanTimerValue1 = 0 gosub StartCylinderPushing return #StopBadScanTimer2 BadScanTimerValue2 = 0 gosub StartCylinderPushing return #StopBadScanTimer3 BadScanTimerValue3 = 0 gosub StartCylinderPushing return #StopBadScanTimer4 BadScanTimerValue4 = 0 gosub StartCylinderPushing return #StartCylinderPushing CylinderPushing = ON StartPushCylinderTimerValue = timer print "Start pushing" return 'ftom StartCylinderPushing #CheckCylinderPushingTimer if timer - StartPushCylinderTimerValue > CylinderPushingPeriod then goto StopCylinderPushing return 'from CheckCylinderPushingTimer without doing anything because CylinderPushingPeriod was not over #StopCylinderPushing StartPushCylinderTimerValue = 0 CylinderPushing = OFF print "pushing stopped" return ' from CheckCylinderPushingTimer with Cylinder off #CheckCylinderPushingTimer if timer - StartPushCylinderTimerValue > CylinderPushingPeriod then goto StopCylinderPushing return 'from CheckCylinderPushingTimer without doing anything because CylinderPushingPeriod was not over #StopCylinderPushing StartPushCylinderTimerValue = 0 CylinderPushing = OFF return ' from CheckCylinderPushingTimer with Cylinder off 'if the transportationspeed is not constant you could measure the speed 'with to lightbarriers if lightbarrier turns off store the timervalue 'the difference of two values is proportional to the speed 'if the distance between the lightbarriers is 10cm 'the timeperiod the moved from the scanner to the cylinder 'is (Value2 - Value1) * 7 'so the waittime for the push is automatically adjusted to the 'speed of the packet-transportation i#ve compiled the program in the IDE and testet it there it seems to work as i want to before storing the program in the cc1 remove the "print" -orders be commenting them of "print "StartTimer" make " 'print "StartTimer" with a leading " ' " that makes the basicstatement to a comment that is not compiled otherwise the checking-frequency will be to low for secure detecting BadScan-Signal and switching ON/OFF the cylinder so i would like to read from you how it works or what questions you have greetings sl > > The chance that I miss the trigger or see it to late is to big. > > So I dare you...... > Mathy > > > > > > > > > > > > Hallo, > > > > > > > > Hallo, (ich bin hollander, so veruntschuldige mein Deuts) > > > Macht nichts, kannst du mir dein Problem nochmal auf englisch beschreiben (auch per Mail)? > > > Ich weiß zwar etwa was du meinst, aber nur etwa! > > > > > > Cu Rene, > > > alias Topmail > > > > > Hello Rene, > > > > are you using a c-control 1 or a c-control 2 > > > > the cc2 is 25 times faster than cc1 > > > > a much faster possibility would be using an Atmel AVR > > MCU > > > > there is an IDE with wich you can Programm in Basic > > > > it's called BASCOM > > > > AVRs have a risc architecture and are VERY fast > > > > you can even buildt MP3-Player with them > > > > did i understand right > > > > your programm is waiting for 100ms-Pulses signaling > > "no read" from the scanner ? > > > > and after a specific time a cylinder must kick off the packet > > from the transportion-rubber ? > > > > what is the minimum time between two signals "no read" from the scanner ? > > > > maybe one possability would be that the signal "no read" starts an interrupt > > > > but i need more information about the times > > > > 140/pm means 140 packets per meter = 7,14mm / Packet? > > > > Speed 40m/min = 667 mm/sec? > > > > means every (667 mm/sec) / (7,14 mm/Packet) = 93,3Packets/Sec ?? > > > > or otherwise 1/93,3 = 10,7 milliseconds/Packet ? > > > > i think some of my suggestions are wrong > > so how is it right > > > > please post numbers with easy to understand units > > > > like Meter / Minute > > > > packets / Meter etc. > > > > sl > > > > > |
| Antwort schreiben |