bit variable declaration

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

bit variable declaration

Post by keshav@solus.in »

Hello

In flow code programming is it possible to declare bit variable manually , if it is possible tell me how to declare it,

i want to create array of variable,

how to create a array of variable.

please reply as soon as possible.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bit variable declaration

Post by Benj »

Hello,

You cannot create a bit variable in Flowcode to use as part of Flowcode though you can do this with C code.

My advice would be to use a Flowcode byte and then use the 8-bits as 8 seperate flags.

To set flag 0 - bit 0
flags = flags | 0x01

To set flag 3 - bit 3
flags = flags | 0x08

To clear flag 0 - bit 0
flags = flags & ~0x01

To clear flag 3 - bit 3
flags = flags & ~0x08

To test flag 0 - bit 0
result = if(flags & 0x01)

To test flag 3 - bit 3
result = if(flags & 0x08)

8-bit microcontrollers can only handle a minimum of 8-bits anyway so even if you created a structure in C that used bits the code would be actually be using the technique as shown above.

Hope this helps.

keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

Re: bit variable declaration

Post by keshav@solus.in »

thank you for your valuable reply

keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

UNABLE TO SEND STRING VALUE

Post by keshav@solus.in »

Hello

i am using 16f1933 pic micro controller,

using component RS232 macro function sending and receiving string value,

In calculation part i mentioned string command value bellow :
string[0]=0xaa
string[1]=0x01
string[2]=0x00
string[3]=0x00
string[4]=0x00
string[5]=0x01
string[6]=0x00
string[7]=0x2d
string[8]=0xa0


i want to send and receive above string structure i am unable to receive and send string

in rs232 component macro called RS232 STRING SEND FUNCTION in parameter column i mentioned string variable,

i am unable send string using RS232 STRING SEND FUNCTION please suggest me how to solve this problem.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bit variable declaration

Post by Benj »

Hello,

The send and recieve string functions rely on the fact that the string is null terminated. Because you are loading 0's into your string this is acting to terminate the string and the rest of the data is not being looked at.

One way to get around this would be to create a loop to send a single byte from the string at a time. Another way would be to remove the 0's from the string data if this is possible.

keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

Re: bit variable declaration

Post by keshav@solus.in »

Hello benz

thank you for reply

please can you send me the sample code for this issue,

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bit variable declaration

Post by Benj »

Hello,

This example doesn't simulate correctly but should run correctly on hardware.

Please can you ensure that you ask future Flowcode related questions in the Flowcode area of the forums, thanks.
Attachments
Flowcode1.fcf
(6.5 KiB) Downloaded 252 times

keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

Re: bit variable declaration

Post by keshav@solus.in »

thank you Benz

its working fine,

please can you send me the sample flow-code for string receive.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bit variable declaration

Post by Benj »

Hello,

Why not try and have a go at creating this yourself.

Simply perform a RS232 read byte in a loop. If a byte is received then add it to the end of the incoming string by using an index variable. After the byte has been assigned to the string increment your index variable and start the loop again. If a timeout value of 255 is received then we have finished receiving data and we can exit the loop. The index variable will then tell you exactly how many bytes were received.

keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

Re: bit variable declaration

Post by keshav@solus.in »

HELLO BENZ

thank you Benz,

I tried but i would not get the out put ,

for your kind reference i attached the string-receive flow code file,

please help me out urgently ,
Attachments
String RECEIVE.fcf
(7.5 KiB) Downloaded 245 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: bit variable declaration

Post by Benj »

Hello,

The attached example should work for you.
Attachments
String RECEIVE.fcf
(8 KiB) Downloaded 269 times

keshav@solus.in
Posts: 19
Joined: Tue Sep 07, 2010 7:03 am
Contact:

HI-TECH C COMPILER FOR 16F1933 MICRO CONTROLLER

Post by keshav@solus.in »

Hello

i am using pic16f1933 micro-controller,

i am unable to receive single character also using flow code program,


for your kind reference i have attached CHAR-RECEIVE.flow code file ,

same program working fine with pic18f8722 micro controller development board,

please go through CHAR-RECEIVE.flow code program,

if any issue related HITECH c compiler and PIC 16F1933 micro controller,

please let me know as soon as possible,
Attachments
CHAR-RECEIVE.fcf
(8.5 KiB) Downloaded 262 times

Post Reply