CANopenNode / CANopenDemo

CANopenNode tutorial and testing
Apache License 2.0
44 stars 31 forks source link

Configure TPDO 3 in demoDevice #7

Open sumitbilam opened 11 months ago

sumitbilam commented 11 months ago

Hello there,

I am following https://github.com/CANopenNode/CANopenDemo/blob/master/tutorial/PDO.md and running two demo devices (giving them node id 4 and 5, both devices in operational and made the node 1 as commander device and running "cocomm" utility) and was able to do the following: cocomm "4 w 0x1802 1 u32 0x80000000" cocomm "4 w 0x1A02 0 u8 0" cocomm "4 w 0x1A02 1 u32 0x21100120" cocomm "4 w 0x1A02 0 u8 1" cocomm "4 w 0x1802 1 u32 0x00000384"

change the value at 0x2110[1]: cocomm "4 w 0x2110 1 u32 0xAABBCCDD" I can see TPDO 0x384 triggered (on candump)

But when I tried to map TPDO x384 to any sub-index (other than 1) let say sub-index 3 of 0x2110; for instance: cocomm "4 w 0x1802 1 u32 0x80000000" cocomm "4 w 0x1A02 0 u8 0" cocomm "4 w 0x1A02 1 u32 0x21100320" (Note: changed the sub-index here from 1 to 3) cocomm "4 w 0x1A02 0 u8 1" cocomm " w 0x1802 1 u32 0x00000384"

and change the value of this variable, cocomm "4 w 0x2110 3 u32 0x11223344" it did not trigger the TPDO, it seems it only trigger the TPDO3 when I change something in 0x2110[1] not at 0x2110[3]

Am I missing some PDOs fundamental here? Can't we jump to any subindex of any variable (0x2110) in my case or will trigger only happen if sub-index 1 value is changed and it will also bring the other sub-index value (sub-index 3 in this case) with it, because that I can see on candump but if I only do cocomm "4 w 0x2110 3 u32 0x_differnet_value_now" I dont see any TPDO from 0x384.

Thanks,

CANopenNode commented 10 months ago

See PDO communication parameter for information, how to trigger TPDO. Most simple is event timer. Transmission on Change of State is not standard behavior, but application can do that as in "demo" example, see https://github.com/CANopenNode/CANopenDemo/blob/master/demo/CO_application.c#L112

sumitbilam commented 10 months ago

https://github.com/CANopenNode/CANopenDemo/blob/master/demo/CO_application.c#L112 says: "variable can be changed by SDO" but that was I was doing by: cocomm "4 w 0x1802 1 u32 0x80000000" cocomm "4 w 0x1A02 0 u8 0" cocomm "4 w 0x1A02 1 u32 0x21100320" (Note: changed the sub-index here from 1 to 3) cocomm "4 w 0x1A02 0 u8 1" cocomm " w 0x1802 1 u32 0x00000384"

can't we change the variable using SDO service (as shown above) or it has to be re-generated (OD.c) via EDSEditor.exe because I can see the mapping in OD.c: .o_2110_variableInt32 = { .dataOrig0 = &OD_RAM.x2110_variableInt32_sub0, .dataOrig = &OD_RAM.x2110_variableInt32[0], .attribute0 = ODA_SDO_R, .attribute = ODA_SDO_RW | ODA_TRPDO | ODA_MB, .dataElementLength = 4, .dataElementSizeof = sizeof(int32_t) },

thanks,

CANopenNode commented 10 months ago

There are many possibilities, how to change an OD variable: PDO, SDO, application, initial value from eeprom, OD editor, ...