Page 1 of 1

Digital Output Write whole 16 bit word

Posted: Wed Mar 02, 2011 10:15 pm
by resodad
Hi Lubin,
How can I send a 16 bit number to port B? The block only accepts a boolean type.
Also, please clarify the use of "Exact Simultaneous Write" in the digital output block.
Thanks,
John

Re: Digital Output Write whole 16 bit word

Posted: Sun Mar 06, 2011 10:56 pm
by LubinKerhuel
Hi John,
resodad wrote:How can I send a 16 bit number to port B
In the blockset current version, this is a pain to do as you will have to decompose each bytes of your 16 bits number to feed a write block.
I should probably write another digital write function for this! Anyway, waiting for it, I would recommend to use the C call function block! The C function is quite straight here.
resodad wrote:Also, please clarify the use of "Exact Simultaneous Write" in the digital output block.
In the case that you are writing more than 1 bit,
Actions when exact Simultaneous Write is checked:
- Read port value (on LATx register) and store the value in intermediate variable
- Modify the variable that depends on the values of the the simulink block input.
- Write the resulting variable back to LATx register.

Actions when exact Simultaneous Write is NOT checked:
- Modify the LATx register depending on the values of the simulink block input.
With this last method, bits are modified one by one thus bit change "is not simultaneous".

I hope I make it clear.

Re: Digital Output Write whole 16 bit word

Posted: Mon Mar 07, 2011 3:43 pm
by resodad
Thanks Lubin,
I will try the C file block; I am sure it is better than what I did. I attach my simulink file anyway for those of us who are scared of C :?
Thanks for the clear explanation of simultaneous write.
Cheers,
John