bit variable declaration
Moderator: Benj
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
bit variable declaration
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.
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.
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
UNABLE TO SEND STRING VALUE
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.
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.
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
Re: bit variable declaration
Hello benz
thank you for reply
please can you send me the sample code for this issue,
thank you for reply
please can you send me the sample code for this issue,
- 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
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.
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 295 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
Re: bit variable declaration
thank you Benz
its working fine,
please can you send me the sample flow-code for string receive.
its working fine,
please can you send me the sample flow-code for string receive.
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
Re: bit variable declaration
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 ,
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 283 times
- 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
Hello,
The attached example should work for you.
The attached example should work for you.
- Attachments
-
- String RECEIVE.fcf
- (8 KiB) Downloaded 324 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 19
- Joined: Tue Sep 07, 2010 7:03 am
HI-TECH C COMPILER FOR 16F1933 MICRO CONTROLLER
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,
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 304 times