Pc Lap Counter
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Pc Lap Counter

Logiciel de comptage
 
HomeHome  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  

 

 Serial Port Output for Light Control (But not hardware specific)

Go down 
3 posters
AuthorMessage
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty15/1/2013, 08:31

Guy

From some other posts, I understand you're not comfortable with some electronics, and this made me think - I've dealt with PIC & Arduino processors, and some people don't want to pay out on Phidgets as they are a bit more expensive.

So, would it be possible to create an "Effects" Serial Port - Instead of outputting an actual hardware command, you could just list how the serial commands work and then those who are able to can develop their own hardware solutions - maybe even share their work and open up the hardware interfaces that PCLC uses?

I'm on Scalextric Digital, so we could have a port per driver, and maybe a 7th for Race Control - each port hooked up to a custom programmed controller.. probably Arduino in my case, and then they control the lights, maybe even a small LCD showing stats like Zoom? Could even add RFID functionality, by allowing something to come back from the feed.. It would then be up to the user themselves to interpret the code and handle updates!



Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty3/3/2013, 17:00

Hi,

here is the protocol communication that i could implement in Pc Lap Counter, do you think arduino can deal this kind of protocol ?
In Pc Lap Counter you will be able to setup the COM parameters (COM number, baud, etc..) and it will write and read data commands from the COM port like this (simple write and read string):
Here is the Protocol description


Last edited by guy on 6/3/2013, 17:51; edited 1 time in total
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty4/3/2013, 00:45

Guy,

I believe this protocol would be fine to implement! I'm sure the PCLC community would speak loudly if there was a major issue!

I note the addition of Inputs from the device - Could i suggest you consider an RFID input as Arduino's can have RFID scanners attached and can then spit the tag ident back to PCLC... eg... "RFID[LANE NUMBER][TAG NUMBER]"

I am away at a event right now so will probably not start working on a sketch basis until next week.

Jay
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty4/3/2013, 11:54

ok, i will add RFID tag number in the input protocol, hope to begin the developpement next week.
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty4/3/2013, 12:18

Thankyou for adding RFID, and hope the development goes well for you!!
Good luck!

cheers
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty4/3/2013, 17:02

jaydrive2000 wrote:
I am away at a event right now so will probably not start working on a sketch basis until next week.

Jay

Protocol can still change during developpement so you have time Wink
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty5/3/2013, 15:00

guy wrote:
jaydrive2000 wrote:
I am away at a event right now so will probably not start working on a sketch basis until next week.

Jay

Protocol can still change during developpement so you have time Wink

Good - I can sort my duff head out first then XD!
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty6/3/2013, 17:58

ok , here is the final protocol description: http://www.pclapcounter.be/PcLapCounter_arduino_protocol.pdf
Just ask me if you need a pre-release version of Pc Lap Counter 5.26.
I placed a order for a Arduino UNO, as soon i receive it i will write a sketch example

cheers
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty6/3/2013, 22:43

Guy, download the Arduino IDE from Arduino.cc now, it can take a little while to unzip from the zip file. (so many files!), and you can probably make a headstart on writing up some of the sketch. (The IDE isn't included with the Arduino boards because the IDE can update at any time.)

If you can supply a pre-release of 5.26 so that I can test, that would be good.
Cheers!

Jay
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty7/3/2013, 21:29

Jay,

You can download beta of Pc Lap Counter 5.26 here
Guy


Last edited by guy on 12/3/2013, 13:07; edited 1 time in total
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty7/3/2013, 21:52

Thankyou guy,
I will start tinkering tomorrow!
Back to top Go down
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty9/3/2013, 15:08

Guy,

Just making a start on the sketch today, but I seem to have a glitch coming up.. I know it's BETA s/ware but thought I'd raise it....

Serial Port Output for Light Control (But not hardware specific) Arduin10

As you can see my Arduino attaches to COM 21.... but PCLC seems to be talking to COM1 (which is a hardware port on my machine).... if I leave it on COM 1, that error doesn't occur.

I've been getting the Arduino to send the appropriate serial string, but PCLC does not respond, nor am I seeing response via the Serial Port. Not sure if it's the Serial comms or if it's my Arduino acting up at present but I will keep tinkering.

Cheers

Jay
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty9/3/2013, 19:46

Jay,

For your information Pc Lap Counter support only COM1 to COM16
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty9/3/2013, 19:53

Ah ha, need to change the port number then... Cheers!
Back to top Go down
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty9/3/2013, 21:16

Got good coms between Arduino & PCLC Now!

So far I've tested sending the Input Commands to PCLC, haven't got the other way just yet.
Start Finish Line - OK
Pit In - OK
Pit Out - OK
Start Race - OK
End Race - OK
RFID Cards - Both Driver & Lane Cards OK.

Suggestion to anyone looking to make RFID driver stations using this... Have a Lane Card ID stored in the Arduino when you load the program to the terminal, and then the Arduino can send it near immediately after scanning a driver or car tag. IE..


Code:

void SendRFID(string drivertag, string lanetag)
{
Serial.print("[RFdrivertag]");
delay(100); // added just to let PCLC handle data - not sure if needed but good idea during testing.
Serial.print("[RFlanetag]");
}

The above is only an example, tweak to suit your needs.
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty11/3/2013, 13:46

I'am happy that the input command is working, on my side i think output command should work also.
About RFID and drivers station: really nice that we can store the Lane Card ID in the Arduino but i suppose you will need a Arduino board PER driver station and at this moment Pc Lap Counter only take care of 1 Arduino board so i think at this moment RFID driver station is not possible silent
This week i will release version 5.26, multiple Arduino board will be supported later.
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty11/3/2013, 14:10

There is a way to make multiple arduino's talk between themselves and send it through a Master Arduino unit! There's also a SPI library which could work. If i get a jig going I'll post schematics and code.

In addition to "Serial.begin(9600)" which does the hardware USB port on Arduino, you also have the "SoftwareSerial" library which can be used to create additional 'virtual' serial ports on the Arduino which would hook into the RFID Scanners.

softwareSerial rfidlane1(rx,tx); // creates port for RFID Scanner Lane 1
softwareSerial rfidlane2(rx,tx); // creates port for RFID Scanner Lane 2

rfidlane1.begin(9600); // opens virtual port at 9600
rfidlane2.begin(9600); // opens virtual port at 9600

softwareSerial library does have it's limits in that data can be handled one just one virtual port at a time.

I'll be working on output commands today - I have to do this on my laptop - for some reason ports 1 to 21 are occupied on my desktop PC, still trying to figure that out.


Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty11/3/2013, 14:32

Thank you , well Arduino is really fantastic bounce
Back to top Go down
http://www.pclapcounter.be
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty12/3/2013, 13:11

Pc Lap Counter version 5.26 availabe now at www.pclapcounter.be
Back to top Go down
http://www.pclapcounter.be
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty12/3/2013, 14:30

Excellent - I have comms in both directions now. Okay, my code is a little messy but it's working!
I just need my RFID readers to turn up in the post to do the RFID Reader system, but shouldn't be much bother.


Guy, a thought given one of my group's guys keeps requesting out of me, do you think you could add this at a later date - checkpoint /sector timing? CHK[chkpointid][lanenumber] as an example, much like [SFlnx]
Back to top Go down
guy

guy


Number of posts : 2310
Localisation : Belgique
Registration date : 2006-01-25

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty13/3/2013, 12:47

Some people already asked for Sector timing (see demand section) but at this moment i can't say when it will be availabe, i just can say patience and stay tuned Wink
Back to top Go down
http://www.pclapcounter.be
Jester




Number of posts : 8
Localisation : Asti (Italy)
Registration date : 2009-11-02

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty14/3/2013, 12:35

Hi all
I'm trying to program a sketch to interface PCLC, an Arduino Uno and our new 4 lanes.
Basically i'm would implement power control at first.
I'm new to Arduino so the question may be silly.

When the race start, on the serial port i receive a lot of data. The [PW001] and [PW000] that i must find to use in the control routine are the last ones.
What's the way to read the string, split, compare what's in it and act in accordance?
I've read about strtok function but still haven't time to test it.
Can someone point me in that direction? Maybe what i've thinked is not the right one...

Thanks!!

Jester
Back to top Go down
http://www.massasso.it
jaydrive2000




Number of posts : 83
Registration date : 2012-09-05

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty14/3/2013, 12:46

Jester, if you're that new to Arduino, my advice is to have a look at the Arduino Tutorial I've linked here

http://arduino.cc/en/Tutorial/ReadASCIIString

Just get used to playing with the serial port before you do anything else.

One key thing you need to know, is that data doesn't come in to the serial port as easily as sending it out on Arduino. You need to read a byte at a time and then convert it for string format.

I've got a few bugs in my sketch to sort out, and needs a helluva tidy up but when the 'decoder' for the serial string is finalised I'll share it out. It won't be pretty, I'll warn you now - but it's functional.

Maybe if we get our heads together we can build up a library and make it that little bit easier....
Back to top Go down
Jester




Number of posts : 8
Localisation : Asti (Italy)
Registration date : 2009-11-02

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty16/3/2013, 13:11

Ok, i have a working sketch!
I share the code, can someone tell me if i'm on the right way?
At the moment, it recognizes the output and correctly operate on pin 2 the power control.
Also, it writes on an external LCD connected thru I2C interface a short message on the track status and the countdown.
That's what i've done until now, next step would be send messages with buttons.
Hope this helps.

Code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x38, 16, 2);

// pins for the LEDs:
const int PWRPin = 2;

String inData;
char recieved;
int charsReceived = 0;

void setup() {
  // initialize serial:
  Serial.begin(9600);
  lcd.init();
  // make the pins outputs:
  pinMode(PWRPin, OUTPUT);

}


void loop() {
    while (Serial.available() > 0)
    {
          if (inData.length() <= 7)
          {
            recieved = Serial.read();
            inData += recieved;
          }

          if (inData.length() == 7)
          {
           
            if (inData.compareTo("[PW001]") == 0)
            {
                digitalWrite(PWRPin, HIGH);
                lcd.setCursor(0,0);
                lcd.print("Power On");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[PW000]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("Power Off");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL011]") == 0)
            { 
                lcd.setCursor(0,0);
                lcd.print("1");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL021]") == 0)
            { 
                lcd.setCursor(0,0);
                lcd.print("2");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL031]") == 0)
            { 
                lcd.setCursor(0,0);
                lcd.print("3");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL041]") == 0)
            { 
                lcd.setCursor(0,0);
                lcd.print("4");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL051]") == 0)
            { 
                lcd.setCursor(0,0);
                lcd.print("5");
                lcd.print("          ");
            }
           
            inData = ""; // Clear recieved buffer
           
            }
    }

}
Back to top Go down
http://www.massasso.it
Jester




Number of posts : 8
Localisation : Asti (Italy)
Registration date : 2009-11-02

Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty16/3/2013, 14:42

Another add
Placed a pushbutton on pin 8 and configured it to send a string via serial.
It works!
By now with the button i can start/pause/resume race ([BT04]).
Here's the complete code for the sketch
Sorry, by now it's really a mess but i'll clean it up in the next days.
For now it's enough that it works!

Hope it helps
Very Happy

Jester


Code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x38, 16, 2);

// pins for the LEDs:
const int PWRPin = 2;

char StartRace[7] = "[BT04]";
char RestartRace[7] = "[BT02]";
char PauseRace[7] = "[BT03]";

//input pins
const int StartPin = 8;
const int RestartPin = 9;
const int PausePin = 10;

String inData;
char recieved;
int charsReceived = 0;

int buttonState = LOW;          // the current reading from the input pin
int lastButtonState = LOW;  // the previous reading from the input pin

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  // initialize serial:
  Serial.begin(9600);
  lcd.init();
  // make the pins outputs:
  pinMode(PWRPin, OUTPUT);
  pinMode(StartPin, INPUT);

}


void loop()
{
    while (Serial.available() > 0)
    {
          if (inData.length() <= 7)
          {
            recieved = Serial.read();
            inData += recieved;
          }

          if (inData.length() == 7)
          {
           
            if (inData.compareTo("[PW001]") == 0)
            {
                digitalWrite(PWRPin, HIGH);
                lcd.setCursor(0,0);
                lcd.print("Power On");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[PW000]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("Power Off");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL011]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("1");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL021]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("2");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL031]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("3");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL041]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("4");
                lcd.print("          ");
            }
           
            if (inData.compareTo("[SL051]") == 0)
            { 
                digitalWrite(PWRPin, LOW);
                lcd.setCursor(0,0);
                lcd.print("5");
                lcd.print("          ");
            }
           
            inData = ""; // Clear recieved buffer
           
            }
    }
   
    // read the state of the switch into a local variable:
    int reading = digitalRead(StartPin);
 
    // check to see if you just pressed the button
    // (i.e. the input went from LOW to HIGH),  and you've waited
    // long enough since the last press to ignore any noise: 
 
    // If the switch changed, due to noise or pressing:
    if (reading != lastButtonState) {
      // reset the debouncing timer
      lastDebounceTime = millis();
    }
   
    if ((millis() - lastDebounceTime) > debounceDelay) {
      // whatever the reading is at, it's been there for longer
      // than the debounce delay, so take it as the actual current state:
      buttonState = reading;
    }
   
    // set the LED using the state of the button:
    if( (buttonState == HIGH) )
    {
        Serial.println(StartRace);
        lcd.setCursor(0,0);
        lcd.print(StartRace);
        lcd.print("          ");
    }
 
    // save the reading.  Next time through the loop,
    // it'll be the lastButtonState:
    lastButtonState = reading;

}
Back to top Go down
http://www.massasso.it
Sponsored content





Serial Port Output for Light Control (But not hardware specific) Empty
PostSubject: Re: Serial Port Output for Light Control (But not hardware specific)   Serial Port Output for Light Control (But not hardware specific) Empty

Back to top Go down
 
Serial Port Output for Light Control (But not hardware specific)
Back to top 
Page 1 of 1
 Similar topics
-
» add lap count to serial output (Arduino) [done 5.31]
» use Serial port (com) with PCL
» Version 5.31D - Arduino Serial Output not working correctly?
» Serial port setting for PC Lap Counter
» Invert Output - power control is not working when we pause the race

Permissions in this forum:You cannot reply to topics in this forum
Pc Lap Counter :: Hardware :: Arduino-
Jump to: