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.

Send data from CR1000 via SDM-CAN


schraubehaube Feb 7, 2017 02:37 PM

Hi everbody,

first of all I have to say I am totally new to the SDM family so I hope I am not just too stupid to handle it ;-)

I have the order to check if it is possible to send the 1Hz data on the CR1000 via canbus to an external IMC-System. As far as I understand there is a way to transmit data with the SDM-CAN. But I don't get the point how to define which data and how to setup the CANBUS parameters, because I do not know exactly what CANBUS parameters IMC uses.

My test setup is a simple temp/hum sensor on the CR1000 to have some realistic data. How can I send these values to the CANBUS?

My example is just simple to get the essantial of the code so I put the parameters directly to the comandlines instead off using variables etc.

So what do I have to do to get Hum and Temp into the CANBUS universe?

BeginProg


 Scan (1,Sec,0,0)
  PanelTemp (PTemp,250)
  Battery (Batt_volt)

  VoltSe (Hum,1,mV5000,1,0,0,_50Hz,1.0,0)
  VoltSe (Temp,1,mV5000,2,0,0,_50Hz,1.0,0)
  
  SDMCAN (Canbus_Dest(),0,8,5,2,-1,19,64,64,2,1.0,0)
 
  CallTable Test
 NextScan


EndProg

Thanks a lot

schraubehaube


rlwoell Feb 20, 2017 09:31 PM

It isn't too difficult to write data to a CANBUS using the SDM-CAN interface but it is a bit more involved than a simple one line instruction.  The SDM-CAN manual has a good example in section 4.2.2.  If you don't have the latest manual, Revision 8/13, you can download it from this site under Support/Documents. Note that the manual uses the old instruction CanBus whereas the operating systems now use SDMCAN.

By default/factory settings, the SDM-CAN has the write function disabled.  To enable it, first a jumper must be placed in the correct position (See section 2.2 Internal Jumper Settings) and then in software you also enable the write function by having the switch setting of 3. (See section 3.3, The Datalogger Instruction for data type 32.)

For a 250K baud network and an SDM-CAN device address of zero, the parameters would be:

SDMCAN(3,0,4,5,2,0,32,0,0,0,1.0,0)

The device is now ready to transmit data. If for example you have a temperature variable Ambient that you want to send as a single 16 bit vaiiable the command could be:

SDMCAN(Ambient,0,4,5,2,ID,20,49,16,1,1.0.0)

The term ID is made up from six CAN device parameters, Priority, Reserved, Data Page, PDU Format, PDU Specific, and the source address.

If I can find specific code that I have used, I will post it later.

I hope this helps get you started.


schraubehaube Feb 28, 2017 02:50 PM

Thanks for your help. I seem to get closer to the point where it could work ;-) I will try my new code in the next few days and will be back if I will run into some more trouble.

Thanks again


schraubehaube Mar 1, 2017 08:22 AM

So now I'm stucked again. I don't understand the example from the manual you mentioned. It says

CanBus(Switches,ADDR1,TQUANT,TSEG1,TSEG2,0,DTYPE.....

and Switches is defined as

dim switches(CANREP1)

and

CANREP1=1

As far as I understand Switches has to be an array of 4 because you have to define the internal switches settings in the format ABCD.

Can anyone help me with this challenge.


rlwoell Mar 1, 2017 01:43 PM

From the manual:

3.3.5.11 Set SDM-CAN internal software switches (type 32):

This data type instructs the datalogger to change some internal software switch settings that control the way it works. The new switch settings are read from a specified input location. The settings are encoded within that location in the format of a four digit number. For explanation purposes the four digits are represented as ‘abcd’ where each letter is a digit in the range 0 to 9 which indicates a different type of switch setting.

===================================================

Treat it as a 4 digit number or string.  In this case switch "a" is 0, switch "b" is 0 and switch "c" is 0.  These are the default settings.  Switch "d" needs to bet set to 3 for data transmission.  Therefore the 4 digit number would be "0003".  Since the leading 0's can be left off, the value of "Switches" is effectively "3".  You could write the example above as:

CanBus(1,0,4,5,2 . . . . )

If you wanted switch "b" to be 1 so the SDMCAN returns a 99999 instead of the previous value if a new value is not present the value for "Switches" would be "0103". And then the example command becomes CanBus(103,0,4,5,2 . . .  )


schraubehaube Mar 1, 2017 01:55 PM

Oh, I overlooked that the leeding 0's can be left off.

Thanks for your help


GTProdMgr Mar 1, 2017 05:29 PM

I recommend you take a look at RTDAQ with its program generator (ProgGen) and its

free add-on tool called SDM-CAN Helper. Within ProgGen you can generate SDM-CAN

based programs for a CR5000 that should be able to do what you are hoping to do, and then

adapt them to run on the CR1000. The SDM-CAN helper will also assist you in getting your SDM-CAN

connected to a CR1000 and up and running.

http://www.campbellsci.com/rtdaq

ProgGen is an updated version of the detailed program generator contained in PC9000 software (RTDAQ’s predecessor). ProgGen contains many measurement and setting windows for configuring almost any type of sensor. It is compatible only with the CR5000 and CR9000X dataloggers.

https://www.campbellsci.com/canhelper

SDM-CAN Helper is a free, add-on program for Campbell Scientific's RTDAQ Real-Time Data Acquisition Software. This add-on program walks users through the process of configuring their SDM-CAN device(s), connecting the SDM-CAN device to the datalogger, sending an appropriate program to the datalogger, and setting up that datalogger to collect specific values from the CANbus network.

Users must have a valid installation of RTDAQ on their computer to install the SDM-CAN Helper program.

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