PARKING LOT PROBLEM

kakolon

Member
Hi,
I'm working in the development of a parking lot project. Actually I've got it running great, working with only one car entry. The rutine when a car arrives is the following
- Detect the car with metal detector.
- Once a car is detected, a ticket is printed with a secuential number
- once the person retrives the ticket, the barrier is lifted
- once the car passes the barrier, the barrier goes down.
- End
I use a 18x chip for this project.
The problem is that now I need to have a second car entry, and I can't have two isolated picaxes, doing the job because a need work with only one secuential number, so this means that if entry one prints ticket number 2, then the seconde entry should print ticket number 3.
As I have loops that wait forever, for a sensor to be activated, Im a not able to respond to other actions while Im in that loop.
Ive read about setint, but i dont see that it could work for me.
The best thing could be to use two picaxe sharing the same memory chip, but I also read that this is not posible.
Any suggestions ?

Thanks in advance,
Best regards,
Kakolon
 

Brietech

Senior Member
The new 28X-1 chips can communicate with one another over the i2c bus, and all picaxe chips can communicate with one another via serial link. Using that scheme, you could use a "scratchpad" memory location on one of the chips as the "counter" for your system, and have both chips be able to access it.
 

hippy

Technical Support
Staff member
The solution I'd choose if I wanted an easy life, didn't want to start altering the code to add polling, delivers a Mission/Business Critical solution and is expandable to any number of barriers, would be to add a third PICAXE. An 08 can handle two barriers, a 14M can handle five.

Whenever a barrier needs a number, it asks this third PICAXE for a number, waits for it, then prints it. The PICAXE increments the number, then waits for the next number request. If multiple barriers ask for a number simultaneously then there will be a short delay while one gets serviced first before the other does, but that should be insignificant and not noticeable.

An added advantage is that the code in each barrier control PICAXE will be the same and no complexity of one master / one slave or trying to keep each barrier's ticket count in synch. The 08 and 14M solutions will each have a spare output line which can be used to continually send ticket count and other stats.

'Selling points' for justifying an extra 1 GBP cost include - simplicity of altering the existing code, a single unit to interrogate to find ticket counts, ability to determine which barriers are used most frequently.

The biggest selling point is; if one barrier PICAXE fails, the other can still keep working, even if that does mean having to pull the broken barrier's link to the number serving PICAXE in a worse case scenario.
 

hippy

Technical Support
Staff member
Barrier Code ...<code><pre><font size=2 face='Courier'>GetTicketNumber:
High WakeUpNumberServerPicaxePin
SerIn FromNumberServerPicaxePin,baudRate,b1,b0 ; Get number into w0
Low WakeUpNumberServerPicaxePin
Return </font></pre></code> Number Server PICAXE Code ...<code><pre><font size=2 face='Courier'>Do
If FromBarrier1Pin = 1 Then
w0 = w0+1
w1 = w1+1
SerOut ToBarrier1Pin,baud,(b1,b0) ; Send number from w0 to barrier 1
Do : Loop While FromBarrier1Pin = 1
End If
If FromBarrier2Pin = 1 Then
w0 = w0+1
w2 = w2+1
SerOut ToBarrier2Pin,baud,(b1,b0) ; Send number from w0 to barrier 2
Do : Loop While FromBarrier2Pin = 1
End If
SerTxd(&quot;Total=&quot;,#w0,&quot; Barrier1=&quot;,#w1,&quot; Barrier2=&quot;,#w2,CR,LF)
Loop </font></pre></code>

Edited by - hippy on 26/06/2007 05:11:05
 

kakolon

Member
Hi Hippy,
Thank you very much for your reply.
Some questions I'd like to ask you:
1- Do the barrier picaxe's share the same serial connection to the server picaxe ?
2- I have to handle tickets numbers from 1 to 999999. Do you have an approach for this.
3- The environment where the picaxe's are placed is very noisy, becuse of the electrical motors, I'm afraid that the serial connections will pick up noise. Do you have a tip to avoid this?

Thank you,
kakolon
 

hippy

Technical Support
Staff member
<i>1- Do the barrier picaxe's share the same serial connection to the server picaxe ? </i>

No, a separate signal from and to each barrier would be used. It's possible to use shared lines but it just complicates things software-wise.

<i>2- I have to handle tickets numbers from 1 to 999999. Do you have an approach for this. </i>

Handle the number in the Number Server as you currently are doing in the barriers. Pass over as many bytes as are necessary to represent the number.

I'd use a word and a byte variable. The word going from 0 to 9999 and the byte going 0 to 99, then it's simple to increment and print the number too ...<code><pre><font size=2 face='Courier'>Do
w0 = w0 + 1 // 10000
If w0 = 0 Then
b2 = b2 + 1 // 100
End If
b3 = b2 / 10 // 10 : SERTXD(#b3)
b3 = b2 // 10 : SERTXD(#b3)
b3 = w0 / 1000 // 10 : SERTXD(#b3)
b3 = w0 / 100 // 10 : SERTXD(#b3)
b3 = w0 / 10 // 10 : SERTXD(#b3)
b3 = w0 // 10 : SERTXD(#b3,CR,LF)
Loop </font></pre></code> <i>3- The environment where the picaxe's are placed is very noisy, because of the electrical motors, I'm afraid that the serial connections will pick up noise. Do you have a tip to avoid this? </i>

Shielded cable, balanced lines ( ala RS485 etc ) plus twisted-pair cable, slow baud rates and filter RC's on the inputs should all help to keep noise pickup down.

You can also improve the serial comms, so the Number Server adds a prefix, maybe even a checksum, and there are all sorts of other tricks for using the two wires to guarantee data is valid and correct. Get the basics working first in a noiseless environment, then add anti-interference measures later.

Edited by - hippy on 26/06/2007 16:08:19
 
Top