Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Model train automatic identification using barcode reader with usb connection on pc

Status
Not open for further replies.

Eng_MC

Member level 1
Joined
Nov 16, 2010
Messages
39
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,865
hi, trying to use a barcode reader to automatically identify the model trains as they pass by, and to develop a pc applicsation using visual studio 2010 to show which train is passing and what rolling stock is passing in real time...... have background in C programing looking for advice been trying to learn c++ but read somewhere that c# would be better....... really need some guidance here thanks.....

the barcode reader would be connected via usb to the pc and i want to be able develop an applicaiton that would show which train and rolling stock is passing the barcode reader in real time ....
 

One question is whether you'll get by with a single stationary transmitter/detector pair, or whether you need the 'laser-show' type of scanning reader that we see in stores.

As for the barcode, it must be in a uniform location on the cars.

If it is located on the side of a car, it should be at a preselected height, on a preselected side (right or left).
If underneath it should be at a set position left to right.

The detector should be located close to the barcode. It needs to be able to distinguish a single color stripe going past it. However train cars are of various shapes and sizes, and there will need to be some distance between the detector and the barcode.

You'll probably end up having to make the barcode of reflective tape, with black lines printed on it. A single narrow-beam led (or laser) will illuminate it.

The led/laser probably should be off when no train is present. You can install a photodetector so it goes dark when a train is going by. That will turn on the led/laser.
 
  • Like
Reactions: Eng_MC

    Eng_MC

    Points: 2
    Helpful Answer Positive Rating
hi thanks for the advice.

i have chosen to go with an off the shelf laser barcode detector motorola ds457, fixed position scanner and i am planning to install the barcodes under the trains.

i was advised to use visual basic to develop the application that will show train information on a pc using visual studio 2010. the advise was that it was easiest using visual studio to detect the information coming in from the usb connection to the barcode and use the information in developing the application....... can you give me any advice relating to that.

thanks in advance
 

I have no experience reading barcodes. I don't know if your incoming signals will be high and low volt levels, or numeric values.

If it's the latter, your job is easier. If the former, then you have to interpret the high and low logic signals, to distinguish one number from another.

In older BASIC's, you would open a Comm channel to the serial or parallel port. I suppose a similar command is available for USB.

You should start out printing all data to screen. Detect null strings as well (length = 0).

You'll have to make sure that (a) what goes over the scanner is detected properly, (b) that it is converted into useful data, and (c) that the data is received into your program properly.
 

from the datasheets of the barcode reader it seems that the data that would be sent to the pc would be alphanumeric in nature ....
 

from the datasheets of the barcode reader it seems that the data that would be sent to the pc would be alphanumeric in nature ....

Then your job is easier.

You'll be very lucky if barcodes come into your computer without need for a lot of troubleshooting on your part.

Consider making a barcode possible to read whether it is oriented forward or backward.

You must figure out how to make your program access the incoming barcodes. You will match them to barcodes you have stored in an array beforehand, along with pertinent data that goes with each barcode.
 

ok i was thinking of using 2D barcodes that could be read omnidirectionally so the problem of orientation is solved. but i am thinking of how i could make the pc application read and display all the train information in real time as the train and the rolling stock pass by.
 

If you were using BASIC then it might go something like the following (vastly abbreviated):

------

OPEN "COMM", 1, _USBport

(loop follows)

WHILE trainDetected = _True

INPUT #1, A$

IF LEN (A$) >0 THEN PRINT "barcode: " A$, "info: " info(VAL(A$))

WEND

(& repeat loop)

---------------------

I wouldn't know the C syntax.

If you can find someone's posted code somewhere, that could be your springboard.

Of course you will need to create a database to hold all information. This could be listed in DATA statements within the program. Or it could be in a separate disk file.
 
  • Like
Reactions: Eng_MC

    Eng_MC

    Points: 2
    Helpful Answer Positive Rating
ok thanks i'm going to be using visual basic on visual studio just getting my head around the programming language at the moment. i think i get the gist of what the snippet u have written is going.

i was thinking of using 2d barcodes which have capacity to store more information than the conventional 1d i was thinking of putting all the info on the 2d barcodes so that i wouldn't have to build a a database, and i was thinking it would ,make the coding faster and less complicated what do you think???
 

Now I find that 2D barcodes are the black and white squares I've been seeing printed here and there.

It is made up of black and white pixels. Anyone with a handheld cell phone or iPad can scan it. It tells the name of a website, etc.

Turns out the first use of barcodes was in labeling railway cars.

There's no reason it shouldn't work for you as well.

It becomes a question whether your scanner is fast enough to capture a moving barcode. You may find you need to slow the train down. Or enlarge the pixel size. Etc.
 

it seem my supervisor has decided for us to continue the project using, 1D barcodes and store the train information in file on the pc.

but is there anyway i can be able to detect the direction the train is moving using the barcode reader????
 

I don't know much about barcodes, but I can't see why a 1D barcode cannot be read in either direction, and for the software to automatically figure out the value. However, I suspect that conventional barcode readers (i.e. with built-in intelligence) do not provide an indication of the direction of swipe, I suspect they just output the corrected barcode value, regardless of scan direction.
The trick would be to read two barcodes sequentially : )
 

I don't know much about barcodes, but I can't see why a 1D barcode cannot be read in either direction, and for the software to automatically figure out the value. However, I suspect that conventional barcode readers (i.e. with built-in intelligence) do not provide an indication of the direction of swipe, I suspect they just output the corrected barcode value, regardless of scan direction.
The trick would be to read two barcodes sequentially : )

how would the barcode readers in sequence be able to work out the direction of the train?? please could you explain further thanks
 

I mean two barcode labels on the train, arranged such that the barcode reader traverses one followed by the other.
If the first barcode is 11111111 and the second barcode is 22222222, then you'll know the direction of the train depending on if
you read 11111111 before 22222222 or vice-versa.
 
  • Like
Reactions: Eng_MC

    Eng_MC

    Points: 2
    Helpful Answer Positive Rating
thanks a lot guys....... but i have two other questions.

firstly considering the train and the rolling stock that follow it how will i be able to tell my program that the trains have finished passing?? or that the last cart has passed??

secondly i am going to use the barcodes to literally just number the trains, but other train information i would like to display would probably be stored in a file of some sort and i would have to associate the information for each engine and cart to the corresponding barcode. how can i do this?? i am using visual studio 2010 and using visual basic programming language thanks
 

Something like this? The easy ideas are the best...
Or, if you want to stick to the barcode theme, an 'end-of-train' barcode stuck on the last cart?

You could just have an excel file of the information save it in CSV format, and read it into your program, into an array when the program starts. I don't really use VB so can't comment. However, I'm sure it must be fairly simple, and lots of resources/forums for Microsoft VB help.
 

firstly considering the train and the rolling stock that follow it how will i be able to tell my program that the trains have finished passing?? or that the last cart has passed??

You can use a light sensor, microphone, vibration detector, metal detector, etc.

Or, have your program count the elapsed time since it scanned a barcode, and call it done if it receives no more barcodes after, say, 15 seconds.

secondly i am going to use the barcodes to literally just number the trains, but other train information i would like to display would probably be stored in a file of some sort and i would have to associate the information for each engine and cart to the corresponding barcode. how can i do this?? i am using visual studio 2010 and using visual basic programming language thanks

Your program will need to create arrays which contain the database of all barcodes and all information.

You'll need to search quickly through the array of barcodes as a train passes, so you can display information on each car.

You'll need to notice when a barcode is unrecognized, and add it to a list, with a reminder to modify the database.

While you are developing the system, you can put it in the program as DATA statements (or equivalent syntax).

Later you may have to learn how to do disk input/output, so you can save your database separately from the program. That way anyone can update the database, without exposing your program to corruption.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top