different sampleus time for three ADCs


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: different sampleus time for three ADCs

    Hi,
    That's simply not what DEFINE ADC_SAMPLUS does and it's not how PBP in general works.
    The ADC does not run continuously in the background (well, it CAN on some devices but for those ADCIN doesn't work anyway).

    If you want a reading every second you need to execute the ADCIN command once per second. There are of course many different ways of getting that done depending on your particular needs. The easiest way might be to simply have a counter that keeps track of how many times you've sampled the "fast" channel. If that's 1000 times per second then count to 1000 before sampling the "slow" channels. Another approach is a timer interrupt or using a timer/CCP module and a special events trigger. Since you're still new to this I recommend the simple approach to begin with.

    DEFINE ADC_SAMPLEUS tells the compiler how long a delay it needs to insert between selecting the channel to sample and actually starting the conversion. During this time nothing else gets done. If you set it to 1 second the program will stop for a second while the the S/H capacitor charges - it's not what you want.

    /Henrik.

  2. #2
    Join Date
    Nov 2015
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: different sampleus time for three ADCs

    Well, thank you very much, I think I understood what is needed. I'll set at about 50 us the sampleus time and set with the program the time it has to read the ADCINs.

    I can't mantain this more simple because I'm solving a complex machine with this. I'm controlling temperatures, velocity with a variator, interface with a tablet, etc. The program has growed more than 800 lines and is not finished. I had to deal with scaling and convertions, with real time programming techniques, about 60 parameters, (5 months already) and other details, but it is funny to go completing the puzzle and more the day I put it to work. And this is a machine for my sister, so I'm a volunteer. There are days I think it is too complex so I make some other things, but there are days I advance very well, or nights. I had to implement Bates ejercices for my eyes, one of the more demanded parts in this project, but although it has taken much more time than I thought, it is going well thanks to the help I obtain like this.

    In fact, the next project like this I would evaluate to use a C based compiler because I won't have to scale anything (it uses float vars) and it seem to have more documentation.

  3. #3
    Join Date
    Nov 2015
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Re: different sampleus time for three ADCs

    That of C based compiler was a joke for which I expected some reaction, but nobody told anything!

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: different sampleus time for three ADCs

    [reaction]
    That’s a great idea, I’d recommend Microchip C-30 for exactly that reason among others.
    PBP is very well documented, however you’ll notice all examples of command use are also examples of exactly how not to write a cyclic program.
    ie. a program that gives the illusion of simultaneity.
    [/reaction]
    If it’s a cyclic program that will be broken if delayed, have you considered an external ADC chip? Not that I’ve used one.
    Last edited by Art; - 22nd May 2016 at 12:47.

Similar Threads

  1. PIC 18F1330 - first time, hard time - blink that LED
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st March 2015, 22:33
  2. How best to time a pin state for extended periods of time
    By Hylan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th March 2011, 11:20
  3. DS1904 RTC - How to Convert Binary Time into Real Time/Date?
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd December 2010, 10:45
  4. ADCIN Sampleus time question
    By LinkMTech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th February 2009, 18:28
  5. Linx RF -> HSERIN time delay / time critical app...
    By batee in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th October 2004, 15:04

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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