Page 1 of 1

Comparator PC10f204

Posted: Sun Nov 25, 2018 11:32 pm
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

Re: Comparator PC10f204

Posted: Mon Nov 26, 2018 6:15 pm
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

Re: Comparator PC10f204

Posted: Mon Nov 26, 2018 7:16 pm
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

Re: Comparator PC10f204

Posted: Tue Nov 27, 2018 1:16 pm
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.

Re: Comparator PC10f204

Posted: Tue Nov 27, 2018 8:29 pm
by STibor
Hello!

I attach an example.
Not tested in hardware.

Re: Comparator PC10f204

Posted: Tue Nov 27, 2018 10:44 pm
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

Re: Comparator PC10f204

Posted: Thu Nov 29, 2018 12:31 am
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