Hello,
I have a question. I was wondering if anyone knows how to send an axis position in degrees to a PLC? The customer is wanting to animate an image on the HMI by what degree Axis 1 is at.
Thanks,
Robot_guy
Hello,
I have a question. I was wondering if anyone knows how to send an axis position in degrees to a PLC? The customer is wanting to animate an image on the HMI by what degree Axis 1 is at.
Thanks,
Robot_guy
first establish connection between robot and plc (I hope you use some sort of fieldbus because 6-axis times 32-bit is a lot of I/Os and wires...)
then map current robot position to I/Os that PLC can read. this can be done in few different way but at any rate it will require casting. simple way is to declare signals but they are behaving like integers. so far most people liking simplicity just multiply value by 1000 on robot end and divide by 1000 on PLC side. one can of course use CAST_TO/CAST_FROM to copy bit-by-bit REALs to INTs and then map INTs to SIGNALs. you can cast one element at a time or all at once... robot joint position is available in variable $AXIS_ACT. a brave soul will simply read definition of floating point on Wiki and write some code to parse it (it is a good exercise).
for example, try making real2bits.src which should contain something like:
deffct INT real2bits(f:in)
decl int n, ofs
decl real f
decl char buf[4] ; this is buffer; for casting 32-bit, we only need 4 bytes
ofs=0 ; must use variable for offset... points at location inside buffer, zero means no skipping...
cast_to(buf[],ofs,f) ; write buffer with data from F
ofs=0 ; set it back to zero again...
cast_from(buf[],ofs,n) ; read buffer and store result into N
return n
endfct
Display More
then in $CONFIG.DAT declare signals like
SIGNAL A1 $OUT[101] to $OUT[132] ; Robot axes are A1,A2,...
SIGNAL A2 $OUT[133] to $OUT[164] ; of course you need to pick outputs that are read by PLC
SIGNAL A3 $OUT[165] to $OUT[196]
SIGNAL A4 $OUT[197] to $OUT[...]
SIGNAL A5 $OUT[...] to $OUT[...]
SIGNAL A6 $OUT[...] to $OUT[...]
SIGNAL E1 $OUT[...] to $OUT[...] ; External Axes are E1,E2,... (if you like..)
etc.
and finally in your SPS.SUB, inside USER PLC fold add something like