NewbieFirstPost PIC16F616 or 16LF818


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    2

    Question NewbieFirstPost PIC16F616 or 16LF818

    Hi. This is my first post. Yes, I'm a newbie. Trying to come up with a way to read a variable voltage (from a sensor through an op-amp) using the PicBasic Compiler from MicroEngineering Labs, then convert it to be displayed on a two-digit 7-segment LCD. Is there a standard for doing this? It's not PicBasic Pro so it doesn't allow ADCin, making it more difficult to read ADC inputs. I have to somehow use the PEEK command instead. Is it possible to simply PEEK an input or do I have to somehow store the value in a register then PEEK that? I have analog experience but programming microcontrollers is alltogether different! Is there some simple method to accomplish this? Thank You, Buglow

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Please post your code so we can help you further.

  3. #3


    Did you find this post helpful? Yes | No

    Default ADC is simple

    Directly driving the ADC is pretty simple. Here is a code snip from a PIC 18LF4620 job. This is for an 8 bit result. Change the ADCON2 definition for 10 bits.

    Code:
    GetECG:          '
       trisa.2 = 1
       ADCON0 = %00001001 'Ch2 selected, Go/Done = 0, ADC ON    
       ADCON1 = %00001100 'VRef = Vdd, Vss, <2:0> analog  
       ADCON2 = %00111111 'Left just (=8 bit), ADacq time = 20 Tad, ADClk = RC 
       pauseus 50
       ADCON0.1 = 1      'start conversion
       ADCNotDone:
          if adcon0.1 = 1 then adcnotdone
       ecgval = adresh 
       if ecgval > MaxECG then MaxECG = ecgval   ' find MAX  
       if ecgval < MinECG then MinECG = ecgval     ' find MIN
    'Turn ADC OFF
       ADCON0 = %00000000 'AD OFF, Ch0 selected, Go/Done = 0
    return

    HTH
    BrianT

  4. #4
    Join Date
    Jun 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Pic16f616

    Thank you for the code. I haven't written any yet. I've got the PICBasic compiler from MicroEngineering, the ePIC programmer and several 16F616 microcontrollers. The whole thing is new to me so it may take awhile to get it. The requirement is to sample an analog voltage at power up, convert it to a digital value and display it as 00 on a two-digit LED display, and reassign a momentary "on" button to an "off" button so one button turns the thing on and off, and provide some sort of interrupt so you can always turn it off by pushing the momentary "off" button. The analog voltage comes from a sensor amplified by an instrumentation amplifier. The firmware would have to "zero" the display and convert the input voltage to a pre-determined display range. So, for example, if the range of the sensor is 20mV to 120mV, the display would read, let's say, 00 to 60. But if the sensor voltage were 31mV to 97mV the display still has to read 00 to 60. Since the MCU would know the lower limit (and set it to zero on power-up) that's fine. But how am I going to let the MCU know the upper limit? I'm thinking it might be possible to come up with a calculation that when given the low number would provide the high number. Then the MCU would know how to scale the voltage over 00 to 60. Does anyone think this is reasonably accomplished with a PIC16F616? Has someone already done something like this? Would someone be interested in writing code that would do the above? I may be able to offer some sort of incentive. I'm rather afraid my analog mind has a lot of trouble with the digital side of things...
    Thank You.

Similar Threads

  1. PIC16F616 HWPM Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th April 2009, 09:20
  2. Problem with servo and PIC16F616
    By Forkosh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th November 2007, 21:22
  3. PIC16f628 to PIC16f616
    By JimA in forum General
    Replies: 0
    Last Post: - 22nd October 2007, 14:33
  4. PIC16F616 Comparator problem
    By JimA in forum General
    Replies: 0
    Last Post: - 15th October 2007, 14:56

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts