Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:38 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Q: RP2040-LCD-0.96-M and PicoMite?

     Page 4 of 4    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2129
Posted: 04:45pm 18 Jun 2023
Copy link to clipboard 
Print this post

Ta Mick. 20KHz pwm with adc open 500000,1. Do I search the array for a voltage and start there for sync?

 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 05:36pm 18 Jun 2023
Copy link to clipboard 
Print this post

The way it usually works is you watch the input voltage for the trigger condition. It could be a falling voltage or rising voltage. The actual voltage is usually variable so the user can decide the trigger point. Sometimes there is a short delay then. When you detect that you trigger the ADC to grab a set of samples. You could perhaps do something by connecting a DIN pin to the AIN one and watching for the DIN to either go high or low depending on the trigger direction. The trigger points would be fixed at roughly 1V falling and 2V rising, I think.

Many DSOs run the ADC to grab a large number of samples. The user can then decide the first and last samples to view between - a "window" on the waveform. the start sample is at the left of the screen and the finish sample at the righ. Thus, by changing the sample numbers you can "zoom in" on a section of the trace.

A DSO has a run/stop button. In the run status the ADC storage usually loops round in a circular buffer. In the stop mode it simply stops the ADC and no new samples are added.  If you want to work like this you'll have to emulate a circular buffer using an array and a pointer that loops around - I don't think the ADC command does this, the array is always filled from (0) AFAIK so old samples are lost when the ADC starts. Maybe better to stick with something simpler. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2129
Posted: 06:45pm 18 Jun 2023
Copy link to clipboard 
Print this post

Thanks Mick for the info. it's a messing about thing but if I drew the samples 2 pixels apart then it would show 40KHz.
The DIN to measure frequency and scale adc and drawing samples maybe.
Trying sync ideas. Neat no wiring picomite.
edit I tried this for rising edge but mut keep looping.
do
sync!=pin(gp26)
sync2!=pin(gp26)
loop until sync2! > sync!

   adc start samples!()
Edited 2023-06-19 05:11 by stanleyella
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 07:39pm 18 Jun 2023
Copy link to clipboard 
Print this post

I don't think you can read a pin that's ben allocated to the ADC. That's why I suggested connecting a DIN pin to the analogue one. All you need to do then is wait for the DIN pin to go high (or low) then start the ADC. The DIN connected to the pin shouldn't have any effect. You'll get the interrupt once the buffer is full.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2129
Posted: 07:40pm 18 Jun 2023
Copy link to clipboard 
Print this post

Here's the code for this display.
 OPTION BASE 0        '  based arrays
 OPTION EXPLICIT
 dim count%,sync!,sync2!
 Dim samples!(160)
 Dim old_samples!(160)
 SETPIN GP26, AIN
 SetPin GP18,pwm1A 'this optional test signal comment out
 PWM 1,20000,50   ' 50% = square wave 20KHz this optional test signal comment out
 Pause 100
 adc open 500000,1 'samples per second
 cls
 adc start samples!()'get new samples
 
 for count%=0 to 159
   samples!(count%)=(samples!(count%)*20)+10 'scale 3V samples to 0 to 79 pixels
 next count%
 
 for count%=0 to 159
   old_samples!(count%)=samples!(count%) 'copy samples to old_samples
 next count%

 for count%=0 to 158
   line count%,samples!(count%),count%+1,samples!(count%+1),,rgb(white) 'draw first samples
 next count%
'-------- main loop
 do
   adc start samples!() 'get new samples

   for count%=0 to 159
     samples!(count%)=(samples!(count%)*20)+10 'scale 3V samples to 0 to 79 pixels
   next count%
   '
   for count%=0 to 158
     line count%,old_samples!(count%),count%+1,old_samples!(count%+1),,rgb(black) 'erase old_sample
     line count%,samples!(count%),count%+1,samples!(count%+1),,rgb(white) 'draw new sample
   next count%
   '
   for count%=0 to 159
     old_samples!(count%)=samples!(count%) 'copy samples to old_samples
   next count%
 loop
end
 
     Page 4 of 4    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024