Digital Output Write whole 16 bit word

Post Reply
resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Digital Output Write whole 16 bit word

Post by resodad » Wed Mar 02, 2011 10:15 pm

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

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Digital Output Write whole 16 bit word

Post by LubinKerhuel » Sun Mar 06, 2011 10:56 pm

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.

resodad
Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Re: Digital Output Write whole 16 bit word

Post by resodad » Mon Mar 07, 2011 3:43 pm

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
Attachments
writeWord.mdl
Simulink file to extract bits to write
(55.04 KiB) Downloaded 586 times

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests