Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Logging port state with SDMIO16


msageng Jun 10, 2014 03:29 AM

I'm measuring the on/off state of some motors using a current switch transducer which triggers a transistor, and provides a 5VDC output. My plan is to assess the port state each second and record it, and totalize to determine run time within each five minute period throughout the day.

When I bench test the system by putting a known 5VDC signal on the SDMIO16 ports, I don't see any change in state written to the table. My code as pertains to the SDMIO16 is as follows:

DataTable(Table2,True,-1)
DataInterval(0,5,Min,10)
Totalize(1,MotorState(1),FP2,False)
.
.
.
Totalize(1,MotorState(16),FP2,False)
EndTable

Scan(1,Sec,0,2)
SDMIO16(Setup,IO16Status(1),0,92,0,0,0,0,1,0)
Next Scan

Scan(1,Sec,1,0)
SDMIO16(MotorState(),IO16Status,0,92,0,0,0,0,1,0)
Next Scan


aps Jun 10, 2014 07:44 AM

In the example above you are not calling the datatables within the scans so no data will be stored.


msageng Jun 10, 2014 01:35 PM

I am calling the data tables in my code, I just omitted them here in oversight.


aps Jun 10, 2014 03:36 PM

Do you see the values in Motorstate change when you remove and apply your 5V source?

Can I also advise you check that you refer to the manual to see the input circuit of the IO16 inputs. They are biased to 5V through a high value resistor. Your interface to the sensor will need to actively pull the input low.


msageng Jun 10, 2014 04:15 PM

I don't see any change in MotorState when 5V is applied when looking at the Public table in Connect.

My goal is simply to determine run time of each of the motors using a 5V logic signal. Is there another way to approach this in the setup and programming?


aps Jun 10, 2014 05:10 PM

You need to get the IO16 to see the state before you consider other options, such as having it measure the duty cycle.

I just noticed though that in your first call of the IO16 in the separate scan ou are not actually setting anything but reading the port status which seems a bit strange.

The default configuration is for the IO16 inputs to act as inputs, so you should not need to set it up. Remove that first scan construct, power cycle the system and try again. Please report what the IO16status variable is reading then too.


msageng Jun 11, 2014 01:33 PM

I think I've made some headway in getting the IO16 to talk.

I deleted the first construct and I can see a change of state in the Public table when I place a jumper wire from the channel to ground, so that part is working.

Since this is a transistor output that we're measuring, will this not serve for this application?


aps Jun 11, 2014 04:40 PM

If this is a ground referenced, open collector transistor then you may just be able to connect the transistor between the input and ground. When transitor switches on the IO16 will registor low and when off it will register a high status. This may the opposite logic than you intended but you can either invert the logic with a couple of lines in the program or do it post data collection.


msageng Jun 11, 2014 07:25 PM

The sensor isn't a ground referenced open collector transistor. Supply voltage is applied at the emitter, and the collector is tied to ground through a pulldown resistor.

Just to check to see if I could get any response, I connected it as you suggested and got the voltage on the terminal to drop to 1100 mV (+/- 50).

Unfortunately, this isn't a situation where I can use another sensor, these are the only ones that fit within the physical constraints we have, since they are quite a small package.


aps Jun 12, 2014 07:42 AM

Can you please post details of the sensor so we can work out the best way to connect this.


msageng Jun 12, 2014 11:28 AM

The sensor is a CR Magnetics current switch, model 9321. The datasheet can be found at http://www.crmagnetics.com/Products/Assets/ProductPDFs/CR9300%20Series.pdf

We have the PNP version.


aps Jun 13, 2014 08:32 AM

The voltage drop across the transistor(s) in those sensors make then not directly compatible with logic level Schmitt trigger inputs. However, with the PNP version you have you should be able to generate a voltage compatible with the IO16 input by using the 12V supply and a couple of resistors.

If you connect the sensor orange wire to +12V from the logger power supply, then connect a 10k resistor between the black (output) to the input of the IO16, then connect another 10k resistor between that input and ground, the input should be pulled down close to about 450 mV when off and go up to about 5.5V when the transistor in the sensor switches on.


texagg98 Jul 24, 2014 08:46 PM

This approach worked like a charm! Many thanks for your help.

Log in or register to post/reply in the forum.