Generic Serial Port Device with parameters

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
yaccri
HouseBot Special Member
Posts: 304
Joined: Wed May 07, 2003 2:19 pm
Location: Tel-Aviv, Israel
Contact:

Generic Serial Port Device with parameters

Post by yaccri »

Hi,



I use a serial I/O card that has 14 outputs(A-N). Instead of duplicating all commands 14 times, I set a parameter (%1%) in the command configuration.

However, I don't understand how to set the parameter in the property manager or in the values of the generic serial port device. I tried to put %1% but it doesn't work.



What's the best way to use parameters for the serial device?

Is it possible to put more than one parameter?



TIA,

Yoram.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Yoram,



I'm afraid that I don't understand what, exactly, you are trying to do. Are you trying to send the same thing out all ports at the same time?



Generally, you can setup the Command configuration so that when a Property is changed to a particular value, one or more of the Serial Commands will get sent. If you use the %1% in the serial command string, it will substitute the exact value that has changed into the data stream.



A trick to passing data straight through to the serial command is to create a Property and assign it a value '*' (no quotes). This is a special wild-card value that will cause any unmatched value to be sent to the serial interface with whatever the current value is. I don't think I'm explaining this too well, but hopefully you get the picture.
Scott
yaccri
HouseBot Special Member
Posts: 304
Joined: Wed May 07, 2003 2:19 pm
Location: Tel-Aviv, Israel
Contact:

Post by yaccri »

Hi Scott,



The serial device that I use is for digital I/O. It has 14 'pins' that I can change their state individually to 'high' or 'low', and to read their current state. I use it for controlling relays.

I would like to use a short list of commands and to put the 'pin letter' on the fly.

For example, to have a command "R%1%" (for reading the state, no space between the R and the pin letter), and assign the pin letter on te fly.



I tried the '*' trick, but probably did something wrong. Can you explain in more details? If you can post an example it would be the best (maybe add it to the GaryUK example?).





Many thanks,

Yoram
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Yoram,



Sorry, but I still don't comprehend. I need more information on how you are wanting to set this up, and maybe a bit about the protocol.



Do you want to use one Device with 14 Properties (pin 1-14)? Or 14 Devices with One Property (high,low)? Or one Device with one composite Property (Pin1;Low)? Man, this software is too flexable :wink:
Scott
yaccri
HouseBot Special Member
Posts: 304
Joined: Wed May 07, 2003 2:19 pm
Location: Tel-Aviv, Israel
Contact:

Post by yaccri »

OK Scott, Maybe explaining the protocol will make it clear (or maybe not :D ). I didn't give all the details in the first place in the thought that I only need to understand how to put a parameter in.



We are talking about cards that are connected to a serial ports. The cards can be attached to each other to extend functionality on the same serial port. I use two cards attached to each other and connected to COM1. One card (A) is an analog input card and has 8 pins. It means that it can read the difference in milli-amper between pairs of pins (four pairs). The other card (B) is a digital I/O and has 14 pins. It can be used either as reading if there is a current on a pin (input), or as output for setting a pin's level to high or low and to read its current state.



The command structure is :

Card letter + Command + pin + optional parameter.



For the analog input card I use a command like "ADB" (without the quotes). The A is the card's address. The D stands for "Differential", and the B means the second pair.



For the digital I/O card I use a commands like "BLC", "BHC500" and "BRC"

BLC means card address B, set level to Low on pin C

BHC500 means card address B, set level to High for 5000 microseconds on pin C

BRC means read the current level on card B and pin C.



There are more commands that I intend to use later.



I hope that all this info does not nake things more complicated. If you could just show an example of how to set a parameter, it would be the best. (for example, how to set the command "BLpin" where pin is a parameter).



Many thanks,

Yoram.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Yoram,



Here's a quick sample that I made that has a Device with two Properties (Set Pin High & Set Pin Low). Enter the Pin number in each of these values to have it send BH[pin number] or BL[pin number] (where pin number is the value you entered into the Property.



I suppose that there are different, possibly better, ways to design this, but I just wanted to show you how everything links together. I know the serial stuff is hard to get all linked up, but it's very flexible.



Hopefully this will work for you. I generated the sample config with version 2, but I don't think anything has changed in that area.
Scott
yaccri
HouseBot Special Member
Posts: 304
Joined: Wed May 07, 2003 2:19 pm
Location: Tel-Aviv, Israel
Contact:

Post by yaccri »

You are one of a kind Scott!



The sample is great!

That's what I need, and it works just as want it to.



Thank you so much,



Yoram.
Post Reply