Saturday, 18 March 2017

Cutting code . . .

Cutting code

Probably the part I like least about this project, cutting code.  I started off my career in IT writing bits of C for spatial data manipulation and server software on Unix, but never got into UI and Windows programming, in fact I pretty much hate it.  Which is why I'm a database admin/programmer now I guess any I digress.

Finding example code to do what I wanted was surprisingly hard.  I did find this little gem but it was in Visual Basic from Hackshed.  However it did have Bluetooth code that works straight out of the box ( well after getting the baud rate right ).

With a few little tweaks I managed to get it up and running but as I have no clue how to write VB I got a little stuck on threading and adding bits and pieces to the interface.  Luckily I have proper Windows programmer friends who could had it for me.

So the interface from Hackshed was modified to do the following.

* Drive both motors from -255 to +255. 0 being off.
* Read the RFID reader output.

So currently I'm waiting for my friend to send me back a new version that he converted to C# and added some better handling between the Arduino and the PC.

So what is my aim here.  Well I want the Arduino to just be a relay, I don't want it to have any smarts at all.  The C# interface will basically set and keep track of speed and also the RFID tags it passes over.

Hopeful Operational Theory

 RFID tags being uniquely numbered means that I can use them for location and also function.

The interface will store each tag in a database.  New tags will request the user for details.

Each tag will be used to add location and build a track map using linked lists.

Function Tags will initially be for the following.

1) Reverse for end of track
2) Stop signals ( start and stop ).
3) Speed signs ( for slowing and speeding around turns etc ).
4) Time stop delay ( for stations stops ).

I don't have anything for track switches.  There is commercial product for this so I might use that as it looks nice,

New nodes should be added as they are encountered and placed in the correct location in the list.

Location Tags will identify trains on a portion of track.   This should enable the following.

1) Location
2) Direction ( after passing two tags )
3) Collusion detection and management ( either by right of way or using Stop Signals ) for multiple trains.

Don't hold your breath

Well it's taken me about two years to actually get it to this point, because there is just waayyy too much other cool stuff to do and I want to do it all.

Besides the RFID is a bit flakey so we'll see how it works in practice once I get the new code from my mate ( and I put in all my peripherals instead of his ).

No comments:

Post a Comment