A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
A2D Command on KicChip 8 - kabo...@NorthState.net - May 23 16:02:09 2009
I downloaded the Kic Studio software as well as the KicChip 8 .hex
file from the KicChip WEB page. I then used my PICKit 2 to flash the
.hex file into a PIC12F683. They seem to set the security bit as I
couldn't read the chip after programming.
I then made up a PCB with a LF351 op-amp driving an analog signal to
Pin 3 (ADC 4) and Pin 5 driving a LED through a 2N7000 FET. It's going
to end up controlling the pump on a friend's solar hot water system.
The final program will be a bit more complicated than the code below
8-).
Wrote a simple BASIC program to blink the LED, downloaded it and the
LED did blink as expected.
Next I tried to read the analog input without success.
Here's the program:
DO
a2d 4, W0
IF W0 > 750 THEN
HIGH 2
ELSE
LOW 2
ENDIF
PAUSE 100
LOOP
END
Download the program, CONNECT to the chip, and click on RUN.
Studio never shows any data in W0 (either in the virtual meter or the
Watch window) and the LED never lights. A DVM shows 3.00 volts
directly on pin 3 of the IC. I can run the voltage between 2.41V and
4.29V with no change.
I've spent a bunch of time in the Help files (such as they are) with
no success. To be kind their examples of command usage are sparse.
What am I missing/doing wrong?
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: A2D Command on KicChip 8 - demolitron - May 23 22:52:47 2009
Mnemonically your code looks fine. I'm not a Kic guy, but looking at their website, have
you used to DIRS parameter, or INPUT command, to make sure that the pin AN4 is set as an
input? Otherwise, according to the PIC datasheet the ADC will convert the digital value
on the pin. I don't know if Kic is smart enough to do this for you when you use the A2D
command. And for that matter, the ANSEL state for that PIN must be setup as well. I
don't see anything like that in the Kic studio...
I'm usually one of the first to pass up ASM and move on to high level language stuff but
for this project ASM seems like it would be the ticket. You already have the PicKit2,
(Its awesome btw), so you're all set to do it. MPLAB is all you'd need to download from
Microchip and you'd be on your way. ASM code for what you're doing would be very straight
forward. You'd be able to piece it together from the datasheet examples, a few tutorials,
and perhaps an evening of experimentation.
My first PIC project was an 8-Channel Weigand Interface security system written in ASM...
Nightmare! But I did it and I still use ASM to this day and knowing it has helped me find
out that C compilers sometimes are completely nuts!
Just my 0.02
--- In p...@yahoogroups.com, kabowers@... wrote:
>
> I downloaded the Kic Studio software as well as the KicChip 8 .hex
> file from the KicChip WEB page. I then used my PICKit 2 to flash the
> .hex file into a PIC12F683. They seem to set the security bit as I
> couldn't read the chip after programming.
>
> I then made up a PCB with a LF351 op-amp driving an analog signal to
> Pin 3 (ADC 4) and Pin 5 driving a LED through a 2N7000 FET. It's going
> to end up controlling the pump on a friend's solar hot water system.
> The final program will be a bit more complicated than the code below
> 8-).
>
> Wrote a simple BASIC program to blink the LED, downloaded it and the
> LED did blink as expected.
>
> Next I tried to read the analog input without success.
>
> Here's the program:
> DO
> a2d 4, W0
> IF W0 > 750 THEN
> HIGH 2
> ELSE
> LOW 2
> ENDIF
> PAUSE 100
> LOOP
> END
>
> Download the program, CONNECT to the chip, and click on RUN.
> Studio never shows any data in W0 (either in the virtual meter or the
> Watch window) and the LED never lights. A DVM shows 3.00 volts
> directly on pin 3 of the IC. I can run the voltage between 2.41V and
> 4.29V with no change.
>
> I've spent a bunch of time in the Help files (such as they are) with
> no success. To be kind their examples of command usage are sparse.
>
> What am I missing/doing wrong?
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Re: A2D Command on KicChip 8 - kabo...@NorthState.net - May 24 8:51:40 2009
On Sun, 24 May 2009 02:52:03 -0000, you wrote:
>Mnemonically your code looks fine. I'm not a Kic guy, but looking at their website, have
you used to DIRS parameter, or INPUT command, to make sure that the pin AN4 is set as an
input? Otherwise, according to the PIC datasheet the ADC will convert the digital value
on the pin. I don't know if Kic is smart enough to do this for you when you use the A2D
command. And for that matter, the ANSEL state for that PIN must be setup as well. I
don't see anything like that in the Kic studio...
>
>I'm usually one of the first to pass up ASM and move on to high level language stuff but
for this project ASM seems like it would be the ticket. You already have the PicKit2,
(Its awesome btw), so you're all set to do it. MPLAB is all you'd need to download from
Microchip and you'd be on your way. ASM code for what you're doing would be very straight
forward. You'd be able to piece it together from the datasheet examples, a few tutorials,
and perhaps an evening of experimentation.
>
>My first PIC project was an 8-Channel Weigand Interface security system written in ASM...
Nightmare! But I did it and I still use ASM to this day and knowing it has helped me
find out that C compilers sometimes are completely nuts!
>
>Just my 0.02
>
I ASSUME setting a pin to input means digital input. I am ASSUMING the
compiler is smart enough to generate the code to set up the pin
properly as an analog input; may be a rash assumption 8-).
I have only used ASM on PICs in the past. This looked like a
simple/cheap place to try out the KicChip/BASIC stuff. Then again I've
been wrong before 8-)
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: A2D Command on KicChip 8 - rtstofer - May 24 22:22:07 2009
--- In p...@yahoogroups.com, kabowers@... wrote:
>
> I downloaded the Kic Studio software as well as the KicChip 8 .hex
> file from the KicChip WEB page. I then used my PICKit 2 to flash the
> .hex file into a PIC12F683. They seem to set the security bit as I
> couldn't read the chip after programming.
>
> I then made up a PCB with a LF351 op-amp driving an analog signal to
> Pin 3 (ADC 4) and Pin 5 driving a LED through a 2N7000 FET. It's going
> to end up controlling the pump on a friend's solar hot water system.
> The final program will be a bit more complicated than the code below
> 8-).
>
> Wrote a simple BASIC program to blink the LED, downloaded it and the
> LED did blink as expected.
>
> Next I tried to read the analog input without success.
>
> Here's the program:
> DO
> a2d 4, W0
> IF W0 > 750 THEN
> HIGH 2
> ELSE
> LOW 2
> ENDIF
> PAUSE 100
> LOOP
> END
>
> Download the program, CONNECT to the chip, and click on RUN.
> Studio never shows any data in W0 (either in the virtual meter or the
> Watch window) and the LED never lights. A DVM shows 3.00 volts
> directly on pin 3 of the IC. I can run the voltage between 2.41V and
> 4.29V with no change.
>
> I've spent a bunch of time in the Help files (such as they are) with
> no success. To be kind their examples of command usage are sparse.
>
> What am I missing/doing wrong?
>
You program works in the simulator exactly as written. That meter has a slider that
adjusts the input voltage for the simulator. I don't have a chip so I don't know if it
responds to the actual voltage on the pin. But W0 should show the voltage.
As I watch the simulator on the very first 'run' after entering the program, I note that
the simulator is smart enough to change In2/Out2/ADC2/PWM (physical pin 5) to output. It
doesn't seem that it is necessary to mess with DIRS.
I have ordered one of each of the chips just for giggles. They should be pretty
interesting to play with.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )