Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:46 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 : PicoMite sine waves?

     Page 5 of 5    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2129
Posted: 08:28pm 01 Jul 2023
Copy link to clipboard 
Print this post

I guess a "scope" is asking too much but you get my idea of simple display a wave.. for laughs. I learnt math is not just for boffins! I tried don't sample until adc>say 1V no joy but not tried bigger sample arrays and searching for start there. I just use a real scope not how trigger works just move it.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 08:42pm 01 Jul 2023
Copy link to clipboard 
Print this post

For a DIY scope a Trig input would be very good.
When the pin goes low (say, it could be the other way) you take a string of ADC readings, say 1000.
Now you have your readings you can close the ADC.
now, pick a point, say 200. If your display is 160 pixels wide then plot ADC readings from a(200) to a(360). By changing the 200 value you can pan along the length of the trace. If you plot from 200 to 320 but every alternate value from a() you'll zoom out to fit more waves across the display.

If you want the scope to free run then you could restart the ADC from a SETTICK, although there are other ways.
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: 09:15pm 01 Jul 2023
Copy link to clipboard 
Print this post

I spent lots of time trying sync so any suggestions I will try, thanks.
it's nice to see but not a scope but shows mmbasic can be impressive with a few lines of code and the visual stuff you can do is cool. I tried to update the display as fast without blit or sprite. The sine gen stuff you're doing is rocket science :)
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2137
Posted: 10:16pm 01 Jul 2023
Copy link to clipboard 
Print this post

Another way to see if the ADC has filled its array is to set the last element to an impossible value (eg -1) before starting. In the main loop read it and when it changes the array is full.

My preference is to use interrupts only when there is no efficient alternative and as Mick said, when they are used just set a flag and get back to the main loop as fast as possible. If there are multiple interrupts there is a chance a second may occur while processing the first. Then things can get messy.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 06:54am 02 Jul 2023
Copy link to clipboard 
Print this post

Synchronised scans from a free-running timebase are very old now. They were improved by taking a small amount of the incoming signal and applying it to the timebase to attempt to "lock" it. I had great fun building a valve oscilloscope that never really worked well. :) I think I might still have the tube for it somewhere. lol There's nothing like working with +250V HT and -500V EHT to keep you on your toes. :)

The beauty of a triggered scan is that there is no synch to worry about. You are detecting a leading edge then triggering the ADC to take time slices of the waveform. Once you have the slices you've finished with the ADC and you can look at any area of the waveform as you are just scaling and/or plotting values from the array. Setting the frequency of the ADC samples lets you take slices of slow or fast waveforms. The waveform is always completely stationary when viewing it.

Because you are simply plotting numbers you can do other things:
All the slices will be 0-3.3 as they come in so you can scale them to anything you like to make things easier.
You can add or subtract a value from all elements prior to plotting to give a vertical shift.
You can start your plot from any point in the array to give a horizontal shift.
You can put a coloured graticule on the display.
You can put vertical rulers on screen, which can be moved and the time difference between them displayed.
You can use horizontal rulers to measure voltages in the same way.
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: 10:44pm 02 Jul 2023
Copy link to clipboard 
Print this post

I just found that it should be
math scale samples!(),79/3.3,samples!()
to scale 3.3 to 0-79 for the 160x80 display
it works edit No I am wrong,sorry
Edited 2023-07-03 09:04 by stanleyella
 
     Page 5 of 5    
Print this page


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

© JAQ Software 2024