I've been working on this project for a while, and I've been stuck on the same problem for so long that I need outside help. The project is a synth module that opens up an Atari Pokey chip for VC control of pitch/volume with controls for waveforms. It is simple enough on paper, and I have successfully made the microcontroller code for controlling everything the Pokey can do. The problem is the VC control part. I am using a dsPIC30F4013 as the brain, and it has plenty of channels available for sampling analog voltages. I am running into all kinds of noise/strangeness on the VC signals as they are sampled. The data I end up with is very noisy and inaccurate. Since I am trying to have VC pitch the errors are very audible. I put in a pretty big averaging filter (5 samples) with a little feedback to stop the LSB from toggling, but I am still getting both noise and, from some inputs, bad values.

Would anyone be interested in helping? I know I will have to make information available about what I've done so far, but right now I haven't made any progress in a couple months because of this noise issue. Opening the project up is the only way I know it will get done

If so, do you reserve enough setup time after switching the input channel and before you start the actual sample process (needed to level the sampling capacitor to the actual input value)?_________________Jan

You have the delay already ... a micro second seems adequate as well, provided that the output impedance of the circuit feeding the processor analog input is low enough, for 1 us it might be allowed as high as 4k7.

You have the delay already ... a micro second seems adequate as well, provided that the output impedance of the circuit feeding the processor analog input is low enough, for 1 us it might be allowed as high as 4k7.

How many bits of noise do you have?

I wrote a program to keep track of the highest/lowest values picked up by the A/D, and the results show some promise that it's a software problem. Feeding a constant DC voltage to the A/D I used the built-in code that came with my dev kit compared with my own code.

Taking highest minus the lowest for each case (the A/D is 12-bit, so these are out of 4095):
Dev kit code: 4
My code: 56

I am not using the dev kit code because it is very slow and blocks other processes. If I go that route then I cannot run other code while I wait for the conversion to happen.
So I would like to fix my code, but I am not sure where to start. All my A/D code together looks like this:

Oh I missed this one earlier today for some reason ... a delta of four is not too bad, 56 is a lot ... erm ... ad measurements tend to get messed up when you're developing and the board is connected to the PC (due to grounding trouble), could that be the problem?_________________Jan

It's bed time for me now .. I hear birds waking up ... will see if I can find anything in the data sheets later. It's all a bit different from the pic18 I'm used to ... but I'll be using pic24/30 in the future myself, so this will not be wasted time .

Speaking about waste, for optimal performance on the pic18 I've always been using a timer interrupt to start the conversion and an ad interrupt to stuff the measurements into an array for use by the program itself. That way you don't need waits at all, the processor load will be evened out better, but it's not entirely for free of course._________________Jan

Speaking about waste, for optimal performance on the pic18 I've always been using a timer interrupt to start the conversion and an ad interrupt to stuff the measurements into an array for use by the program itself. That way you don't need waits at all, the processor load will be evened out better, but it's not entirely for free of course.

The code I posted is a little misleading because it's just to test the A/D. In my actual program there is other code running while the sampling and conversion take place.

I was using interrupts for a while in the beginning, but it got messy because some of the code can't be interrupted. For example, writing a 16-bit frequency to the Pokey needs two consecutive write cycles. If an interrupt falls between the write cycles then there is a small span of time where the frequency glitches because it doesn't have all its data. It took me a while to figure out why it sounded like there was some crazy FM going on in the beginning. Instead of constantly switching interrupts on and off I made everything run sequentially.

... I see you are setting ADCON1 to zero, meaning form[1:0] is set to zero as well .. I can't find if that means

Signed fractional, Fractional, Signed integer or integer result format ... is there some other manual describing this ?

When it's set to signed fractional or fractional the AD result is left aligned. meaning large jumps in values for small changes in the LSB._________________JanLast edited by Blue Hell on Fri Jun 13, 2008 2:35 pm; edited 1 time in total

I don't know if you've seen the family reference manual already, it's sort of impossible to find on the microshit site http://ww1.microchip.com/downloads/en/DeviceDoc/70046E.pdf - it explains the control registers a bit at least ... I must say that I've seen better docs, if not that documentation sucks in this case ... but .. the good news is that section 18.25 of the doc linked above has design tips ...

Quote:

Question 1: How can I optimize the system performance of the A/D converter?
Answer:
1. Make sure you are meeting all of the timing specifications. If you are turning the module
off and on, there is a minimum delay you must wait before taking a sample. If you are
changing input channels, there is a minimum delay you must wait for this as well, and
finally, there is TAD, which is the time selected for each bit conversion. This is selected in
ADCON3 and should be within a certain range, as specified in the Electrical Characteristics.
If TAD is too short, the result may not be fully converted before the conversion is
terminated, and if TAD is made too long, the voltage on the sampling capacitor can decay
before the conversion is complete. These timing specifications are provided in the
“Electrical Specifications” section of the device data sheets.
2. Often, the source impedance of the analog signal is high (greater than 10 kΩ), so the
current drawn from the source by leakage, and to charge the sample capacitor, can affect
accuracy. If the input signal does not change too quickly, try putting a 0.1 μF capacitor on
the analog input. This capacitor will charge to the analog voltage being sampled and
supply the instantaneous current needed to charge the 18 pF internal holding capacitor.
3. Put the device into Sleep mode before the start of the A/D conversion. The RC clock
source selection is required for conversions in Sleep mode. This technique increases
accuracy, because digital noise from the CPU and other peripherals is minimized.

and 18.26 says :

Quote:

This section lists application notes that are related to this section of the manual. These
application notes may not be written specifically for the dsPIC30F Product Family, but the
concepts are pertinent and could be used with modification and possible limitations. The current
application notes related to the 12-bit A/D Converter module are:
Title Application Note #
Using the Analog-to-Digital (A/D) Converter AN546
Four Channel Digital Voltmeter with Display and Keyboard AN557
Understanding A/D Converter Performance Specifications AN693

I gave up on using the dsPIC's A/D. I followed every app note and data sheet, but still got noisy/skewed results. I found that by increasing the sampling time about 5x I got much better data, but that ruined the chip's quoted sample rate.

MAY THE SOFTWARE BE WITH YOU!
*============================================================================*
CYBERYOGI Christian Oliver(=CO=) Windler
(teachmaster of LOGOLOGIE - the first cyberage-religion!)
!
*=============================ABANDON=THE=BRUTALITY==========================*
{http://weltenschule.de/e_index.html}

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum

Please support our site. If you click through and buy from our affiliate partners, we earn a small commission.