Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 19:57 29 Mar 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 : CMM2 demo programs

     Page 2 of 4    
Author Message
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 839
Posted: 07:56am 25 Jun 2020
Copy link to clipboard 
Print this post

I've just finished building my CMM2 and HAD to test it with Jim's Pin Tester.
I had ordered 200 Ohm resistors and they turned up at the same time as BigMiks
CMM2 to Breadboard adapter (minus the header pins).
My CMM2 passed Jim's test. I'll use it now to test all the IDC cables I make.
(I know its not pretty - but it works).

Cheers,

Andrew

 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8517
Posted: 12:26pm 25 Jun 2020
Copy link to clipboard 
Print this post

Something a bit different:

Real time Audio analysis and FFT

Option explicit
Option default none
Option VCC 3.308
Const SAMPLESPERSEC = 10000
Const NSAMPLES = 512
Const PLOTFREQ = NSAMPLES\512
Dim integer i, j, imax, imax1, toggle
Dim float a(NSAMPLES-1) , b(NSAMPLES-1), a1(NSAMPLES-1), b1(NSAMPLES-1)
Dim integer c%(179), d%(179),x1(255),x2(255),y1(255),y2(255),y3(255), y4(255)
Dim float m(NSAMPLES-1) , mmax , m1(NSAMPLES-1), mmax1
CLS
For i=0 To 255
    x1(i)= i*2+194
    x2(i)= i*2+195
Next i

'
' First set up some signals using the onboard DAC playing music
' connect PA4 to pin 7 and PA5 to pin 8
'
' start the DAC
'
Play MP3 "TAKE_YOUR_TIME"

'
' convert the signals
'
 toggle=1
 page write 1
 ADC open SAMPLESPERSEC, 7, 8,, adc_done
 ADC start a(), b()
 Text 10,40,"Channel 1",,3
 Text 10,150,"Frequency 1",,3
 Text 10,320,"Channel 2",,3
 Text 10,430,"Frequency 2",,3
Do
 Do
 Loop While j=0
 j=0
 If toggle Then
   ADC start a1(),b1()
   toggle=0
 Else
   ADC start a(),b()
   toggle=1
 EndIf

'
' frequency analyse the signals
'
IF MM.INFO(VERSION)=5.0504 THEN
 If  toggle Then
   math FFT magnitude b1(),m()
   math FFT magnitude a1(),m1()
 Else
   math FFT magnitude b(),m()
   math FFT magnitude a(),m1()
 EndIf
ELSE
 If  toggle Then
   FFT magnitude b1(),m()
   FFT magnitude a1(),m1()
 Else
   FFT magnitude b(),m()
   FFT magnitude a(),m1()
 EndIf
ENDIF
 Box 194,0,MM.HRes-287,MM.VRes,1,&HFFFFFF,0
'
' find the maximum magnitude of the frequencies
'
 mmax=0
 mmax1=0
 For i=1 To NSAMPLES\2-1
   If m(i)>mmax Then
     mmax=m(i)
     imax=i
   EndIf
   If m1(i)>mmax1 Then
     mmax1=m1(i)
     imax1=i
   EndIf
 Next i
'
' plot the samples
'
 For i=1 To 255
   If toggle Then
     y1(i)=130 - a1(i-1)*40
     y2(i)=130 - a1(i)*40
     y3(i)=410 - b1(i-1)*50
     y4(i)=410 - b1(i)*50
   Else
     y1(i)=130 - a(i-1)*40
     y2(i)=130 - a(i)*40
     y3(i)=410 - b(i-1)*50
     y4(i)=410 - b(i)*50
   EndIf
 Next i
 Line x1(),y1(),x2(),y2(),1,RGB(magenta)
 Line x1(),y3(),x2(),y4(),1,RGB(green)
 '
 ' plot the frequency analyses
 '
 For i=2 To 255
   y1(i)=470-m((i-1)*PLOTFREQ/2)/mmax*100
   y2(i)=470 - m(i*PLOTFREQ/2)/mmax*100
   y3(i)=190-m1((i-1)*PLOTFREQ/2)/mmax1*100
   y4(i)=190 - m1(i*PLOTFREQ/2)/mmax1*100
 Next i
 Line x1(),y1(),x2(),y2(),1,RGB(yellow)
 Line x1(),y3(),x2(),y4(),1,RGB(yellow)
 PAGE COPY 1 TO 0
Loop
'
End

Sub adc_done
 j=1
End Sub

Edited 2020-06-25 22:27 by matherp
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 02:12pm 25 Jun 2020
Copy link to clipboard 
Print this post

  Andrew_G said  I've just finished building my CMM2 and HAD to test it with Jim's Pin Tester.
I had ordered 200 Ohm resistors and they turned up at the same time as BigMiks
CMM2 to Breadboard adapter (minus the header pins).
My CMM2 passed Jim's test. I'll use it now to test all the IDC cables I make.
(I know its not pretty - but it works).



If you have this plugged in when the CMM2 cold boots, does it reset OPTIONS?
Micromites and Maximites! - Beginning Maximite
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2989
Posted: 08:42pm 25 Jun 2020
Copy link to clipboard 
Print this post

Using Jim's ColourBar program with my ancient Polaroid FLM1511 monitor (native resolution 1024x768@60Hz) I get mode 1,8; mode 1,16; mode 1,12; and otherwise "Input signal out of range".

What does this mean and is there anything I will likely be able to do about it other than get a different monitor?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2989
Posted: 09:35pm 25 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  Rotating Dodecahedron

 polygon 5,xarr(),yarr(),col(i),col(i)

At this statement I get "Error: Invalid variable". Do I need option base something?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8517
Posted: 09:46pm 25 Jun 2020
Copy link to clipboard 
Print this post

  Quote  At this statement I get "Error: Invalid variable". Do I need option base something?


Please update the firmware, this command changed while UK/Canada post were messing around

  Quote  What does this mean and is there anything I will likely be able to do about it other than get a different monitor?


All other modes use 640x480@75Hz as the actual resolution. Sounds like your monitor can't handle this although it has been a standard for a long time now
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 10:14pm 25 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  Something a bit different:

Real time Audio analysis and FFT


Now we're talking!!!

Jim
VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9030
Posted: 11:33pm 25 Jun 2020
Copy link to clipboard 
Print this post

Impressive.  
Smoke makes things work. When the smoke gets out, it stops!
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 839
Posted: 04:51am 27 Jun 2020
Copy link to clipboard 
Print this post

Sorry to cut across the current thoughts but I wanted to answer CG:

  Quote  If you have this plugged in when the CMM2 cold boots, does it reset OPTIONS?


Cold boot - Yes the options are reset! - 1) is that what you expected? - why?

AND without it plugged in, if you set options, plug it in and then run Jim's test, any options are still there.

BUT with it still plugged in (with or without running Jim's test), if you set options, they are NOT set, AND all options are reset.

2) is that what you expected? - why?

Cheers,

Andrew
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 06:26am 27 Jun 2020
Copy link to clipboard 
Print this post

The pull-up used during boot to initiate a reset is not strong enough to handle the load my tester puts on it.
When the pin tester is plugged, it keeps pin 40 low during the boot sequence.

When you change some options such as keyboard, the system does a reboot and if my tester is plugged in, you loose all settings.

If that's a problem, you could put a switch on pin 40 and only close it during testing.

Jim
VK7JH
MMedit   MMBasic Help
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 839
Posted: 07:21am 27 Jun 2020
Copy link to clipboard 
Print this post

Thanks Jim,
I was intrigued because CG was obviously expecting something.
NOT a problem for me as I only have defaults (at present - very early days for me though).
If "someone" writes a manual for your tester, or even develops a more sophisticated version, it would be very simple to put a jumper to pin 40 (off for reboot, in for test). . .

Thanks for your contributions to CMM2 and MMEdit too!
Cheers,

Andrew
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 07:48am 27 Jun 2020
Copy link to clipboard 
Print this post

It SHOULD have a switch.
It is always good practice to plug things in while shut down and that is something I should have allowed for.

I will modify mine cos I did get caught by the resetting today.

Jim
VK7JH
MMedit   MMBasic Help
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2282
Posted: 01:41pm 27 Jun 2020
Copy link to clipboard 
Print this post

  Andrew_G said  I was intrigued because CG was obviously expecting something


purely my opinion:

alas, i fear the current use of pin 40 for a 'factory reset' function at startup pretty much precludes using that pin for anything else. it would be good practice to cut the wire running to this pin on any 40-way cable you attach to the back of a CMM2.

we went through this several years back when the MM2 (MX170) came out, with various people getting unexpected factory resets due to the MX170 seeing a signal path between the console TxD and RxD at startup (this is how you initiated a factory reset on MX150 and earlier versions of MX170 MMbasic). the problem was that while most USB to serial bridges kept the two pins isolated most of the time, just occasionally the stars would align and a MX170 would unexpectedly wipe itself clean.

in the end, the solution was to switch to requiring a sequence of "!" characters at 38400 baud before doing the factory reset. this COMPLETELY cured the problem, a problem that had kept the best minds of the forum befuddled for some months.


the same sort of problem also plagued (and perhaps also sometimes continues to plague) ATmega based arduinos. to enable 'automatic programming' most arduinos have a small capacitor connected between DTR of the USB to serial bridge and RESET on the processor. this was a great way for the arduino IDE to remotely reset the processor in order to start talking to the bootloader and upload a new sketch. unfortunately, the capacitor was also really good at injecting a 9 volt pulse into the RESET pin, which would wipe the bootloader if other pins on the processor were tied in just the right pattern! the solution was the addition of a clamp diode added to the Arduino Uno revision 3 and later.


cheers,
rob   :-)
Edited 2020-06-27 23:45 by robert.rozee
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 04:06pm 27 Jun 2020
Copy link to clipboard 
Print this post

  robert.rozee said  
  Andrew_G said  I was intrigued because CG was obviously expecting something


purely my opinion:

alas, i fear the current use of pin 40 for a 'factory reset' function at startup pretty much precludes using that pin for anything else. it would be good practice to cut the wire running to this pin on any 40-way cable you attach to the back of a CMM2.

we went through this several years back when the MM2 (MX170) came out, with various people getting unexpected factory resets due to the MX170 seeing a signal path between the console TxD and RxD at startup (this is how you initiated a factory reset on MX150 and earlier versions of MX170 MMbasic). the problem was that while most USB to serial bridges kept the two pins isolated most of the time, just occasionally the stars would align and a MX170 would unexpectedly wipe itself clean.

in the end, the solution was to switch to requiring a sequence of "!" characters at 38400 baud before doing the factory reset. this COMPLETELY cured the problem, a problem that had kept the best minds of the forum befuddled for some months.

cheers,
rob   :-)


Thank you Andrew, Jim, and Rob. Yes, this is what I was expecting. The pin 40 testing may have become a bit more robust, but it continues to plague users that have anything connected to that pin, including using that pin for SPI 2 CLK. There will be a lot of users that have light skills when it comes to circuitry and will be tripped up by this.
Micromites and Maximites! - Beginning Maximite
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 10:30pm 27 Jun 2020
Copy link to clipboard 
Print this post

If you use pin 40 for SPI2, there will be an external pull-UP which will HELP the reset issue.
I made mistake on my tester board which I will fix with a couple of pins and a jumper. No big deal.

The manual might need a reference to the likelihood of issues but the system works.

Maybe a revision of the motherboard could have a jumper on the backup battery as means of clearing the settings.

Jim
VK7JH
MMedit   MMBasic Help
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1584
Posted: 12:06am 28 Jun 2020
Copy link to clipboard 
Print this post

I asked before if this pin 40 reset thing was a accident waiting to happen. Already it has caused some confusion. What was wrong with a stream of exclamation marks (!) as used for the Micromite?

Bill
Keep safe. Live long and prosper.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 839
Posted: 12:23am 28 Jun 2020
Copy link to clipboard 
Print this post

Here is lousy picture of my mod to the resister ladder posted above to include a jumper to pin #40 (much easier if I'd done that before soldering all of the resistors).
Now all I have to do is to leave the jumper off, or the whole thing not connected, before booting the CMM2.

Andrew


 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2861
Posted: 01:43am 28 Jun 2020
Copy link to clipboard 
Print this post

Hi All,

As the CMM2 has a USB k/b by default cant a particular key sequence be sent to reset options to default it.?

Maybe a string of !!!!!! Or something.

This could be actioned ONLY in the first, say, 5seconds of power up. After 5seconds the string would be ignored...

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 02:56am 28 Jun 2020
Copy link to clipboard 
Print this post

New demoscene for Colour Maximite 2

Soon I will publish a site with all my source codes.

I hope you enjoy the video!
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 839
Posted: 03:27am 28 Jun 2020
Copy link to clipboard 
Print this post

Amazing!  Andrew
 
     Page 2 of 4    
Print this page
© JAQ Software 2024