Comparator PC10f204

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
luibra63
Posts: 36
Joined: Mon Aug 29, 2016 3:21 pm
Has thanked: 3 times
Been thanked: 6 times
Contact:

Comparator PC10f204

Post by luibra63 »

Hi all
I use a PIC10F204 for a simple project.
I need actived a led when the voltage at the pin GP0 is major at the 06V, internal refernce voltage at the comparator.
I read that the flowcode not simulate the internal comparator, is correct?
when I tried at connect a potentiometer at pin GP0 for simulate,is not was possible, why?
i tried set a comparator with C code, is it possible?, and the internal register, for example "CMCON0" is simulated in flowcode?.
for this simple project I can programmer in assembly code, but I would like tried wìth flowcode. thankyou for your advises and sorry for my bad english.
I attack an example
Attachments
pic_comparator.pdf
(196.33 KiB) Downloaded 190 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: Comparator PC10f204

Post by Benj »

Hello,
I read that the flowcode not simulate the internal comparator, is correct?
Currently Flowcode doesn't support internal comparator modules. If you want to use them you have to use your own C code inside C icons to drive the peripheral registers. We have tried a number of times to include comparators but they differ so much from device to device that it quickly gets very complicated.
when I tried at connect a potentiometer at pin GP0 for simulate,is not was possible, why?
The ADC components require an ADC peripheral and an ADC capable input pin. The 10F204 has neither of these features just a comparator.
i tried set a comparator with C code, is it possible?, and the internal register, for example "CMCON0" is simulated in flowcode?.
The C code icons won't simulate, they will be ignored by the simulator. However they will compile and work on the target device.
thankyou for your advises and sorry for my bad english.
You are very welcome and your English is very good, both clear and understandable :D

luibra63
Posts: 36
Joined: Mon Aug 29, 2016 3:21 pm
Has thanked: 3 times
Been thanked: 6 times
Contact:

Re: Comparator PC10f204

Post by luibra63 »

Thanks Benj
All is clear, I'll try tomorrow.
Flowcode is very good, I'm not a programmer, I'm hardware specialist, and flowcode for me is perfect for realized a my Christmas project.
only question, exist one list of command "C" code correct or different for flowcode?,
for example,
tes_bit , set_bit ecc.
thankyou very much

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: Comparator PC10f204

Post by Benj »

Hello,

For general purpose bit manipulation using a C code icon you can call these functions.

Code: Select all

set_bit(var,bitno) 	//Sets a single bit
clear_bit(var,bitno) 	//Clears a single bit
test_bit(var,bitno) 	//Tests a single bit 
for example

Code: Select all

set_bit(FCV_MYVAR, 0);
Will set bit 0 in the MyVar Flowcode global variable.

For more specific register manipulation on a PIC device where you want to specifically reference a bit in a register by name you can also use these functions.

Code: Select all

st_bit(var,bitno) 	//Sets a register bit
cr_bit(var,bitno) 	//Clears a register bit 		
ld_bit(var,bitno,val) 	//Loads a register bit as a 0 or 1 	
ts_bit(var,bitno) 	//Tests a register bit and returns true or false 	


for example

Code: Select all

cr_bit(TRISA,TRISA0);    //Convert Port Pin A0 into an output
st_bit(PORTA,RA0);     //Set output pin A0 high
You can refer to the device datasheet for the register names and bit names.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: Comparator PC10f204

Post by STibor »

Hello!

I attach an example.
Not tested in hardware.
Attachments
COMPARATOR_10F204.fcfx
(9.58 KiB) Downloaded 224 times

luibra63
Posts: 36
Joined: Mon Aug 29, 2016 3:21 pm
Has thanked: 3 times
Been thanked: 6 times
Contact:

Re: Comparator PC10f204

Post by luibra63 »

thanks Bengj, very good.
thanks Stibor, fantastic, but for me is difficult, I am only harware man and software is devil for me. :twisted: :twisted:
Anyway I want to understand to try
best regards

luibra63
Posts: 36
Joined: Mon Aug 29, 2016 3:21 pm
Has thanked: 3 times
Been thanked: 6 times
Contact:

Re: Comparator PC10f204

Post by luibra63 »

Hi
I tested firmware send from STibor, perfect funcionally, I changed only configuration pin "CIN-" because I used internal reference value.
For me is very important understend "C code" icon, your example is very exaustive.
Thankyou very much

Post Reply