Home
JAQForum Ver 19.10.27
Log In or Join  
Active Topics
Local Time 09:05 20 Nov 2019 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 : Micromite: Oscillocope, single version

     Page 1 of 2    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 01:05am 27 Oct 2015
Copy link to clipboard 

I've merged the two versions of the scope code into a single CFunction.

This single version now runs on any of the Micromites and supports both the ILI9341 and SSD1964 (800x480 versions only) displays. Shown here on a 64-pin MM+ with a ILI9341 display using my "ultimate" backpack PCB (note the PS2 wiring bodge - perhaps not so ultimate after all )





I've also made some slight performance tweaks and incorporated piclover's changes.

The automatic scaling of the display when low values of usec/division are used is now in increments of one rather than factors of 2 improving the amount of data available for display under certain circumstances.

Finally, I've increased the trigger timeout by 10 but now touching the screen will immediately return control to Basic to allow better integration with a GUI

The following Basic has been tested on 44 and 64-pin Micromites with both ILI9341 and SSD1963 displays but should also run on 28-pin and 100-pin parts with NO changes (note the use of the "npins" CFunction that tells you how many pins the chip you are using has so you can write simple conditional code):


option explicit
option default none
dim integer i,j=0,toggle,channel1buff(MM.HRES/2),channel2buff(MM.HRES/2),microsecondsperdivision=50
dim integer y1pos=90, y2pos=30, c1mvperdivision=500, c2mvperdivision=1000, c1trig=90, c2trig=0
pwm 2,1000,50 'Backlight on Ultimate PCB: omit if not required
if npins() = 100 then
setpin 25,ain 'Channel 1
setpin 21,ain 'Channel 2
endif
if npins() = 64 then
setpin 16,ain 'Channel 1
setpin 12,ain 'Channel 2
endif
if npins() = 28 then
setpin 2,ain 'Channel 1
setpin 23,ain 'Channel 2
endif
if npins() = 44 then
setpin 19,ain 'Channel 1
setpin 10,ain 'Channel 2
endif
colour rgb(white),rgb(blue)
cls
font MM.VRes/240
'
' Starting code for a Micromite based oscilloscope - needs a GUI (volunteers?)
' Runs on uM2 or MM+ with a 800x480 SSD1963 display or 320x240 ILI9341 display
' Maximum conversion rate is approximately 1.8 Megasamples / second on each channel at 10-bits resolution on MM+
' Maximum conversion rate is approximately 0.9 Megasamples / second on each channel at 10-bits resolution on uM2
' The CFunction will automatically compensate for CPU speed but obviously the higher the speed the better
'
'
' Parameters for call to CFunction "scope"
'
' Returns the scaling factor used for the display or a large number if triggering is enabled and has timed out
' Also returns to Basic when no trigger has occured but the screen is "touched" assuming touch is enabled
' A scale factor of 1 means every x-coordinate has a unique value
'
' microsecondsperdivision: specifies the number of microseconds to scale the display for each graticle line
' note: durations less than 100uSec will use scaling. i.e.every other x-coordinate will be missed if scale = 2
' toggle: initialised to 0, used by the CFunction to control its double buffering
' channel1buff: buffer used for channel 1, used as 2 buffers of MM.HRES x 16-bit words
' channel2buff: buffer used for channel 2, used as 2 buffers of MM.HRES x 16-bit words
' y-position for channel 1: specifies the screen position of the zero volts on channel 1 in rows from the bottom of the display
' use any negative number to turn off the channel
' y-position for channel 2: specifies the screen position of the zero volts on channel 2 in rows from the bottom of the display
' use any negative number to turn off the channel
' trigger for channel 1
' specifies the ADC reading and direction to trigger the trace for channel 1 (-1023 to +1023)
' a zero value means triggering is disabled for this channel
' a positive value triggers when the ADC reading passes the trigger value in a positive going sense
' a negative value triggers when the ADC reading passes the absolute trigger value in a negative going sense
' trigger for channel 2
' specifies the ADC reading and direction to trigger the trace for channel 2 (-1023 to +1023)
' a zero value means triggering is disabled for this channel
' a positive value triggers when the ADC reading passes the trigger value in a positive going sense
' a negative value triggers when the ADC reading passes the absolute trigger value in a negative going sense
' NB: if both trigger levels are set to zero the scope will free run
' millivolts per division for channel 1 based on VDD=3.3V
' millivolts per division for channel 2 based on VDD=3.3V
'

do
i= scope(microsecondsperdivision,toggle,channel1buff(),channel2buff(),y1pos, y2pos, c1trig, c2trig ,c1mvperdivision,c2mvperdivision)
if i>1 and i<1024 and j=0 then
print "Warning reduced resolution x"+str$(i)
j=1
endif
if i>1024 then
PRINT "No trigger"
endif
text 2,2,"T:"+str$(microsecondsperdivision)+"us/div"
if y1pos>=0 then text MM.HRES/2,2,"C1:"+str$(c1mvperdivision)+"mv/div",C
if y2pos>=0 then text MM.HRES-2,2,"C2:"+str$(c2mvperdivision)+"mv/div",R
loop
end
'
CFunction npins 'returns the number of pins on the chip in use.
00000000
3C03BF81 8C65F220 3C020661 7CA5D800 3444A053 50A40009 2402002C 8C64F220
2443A053 7C84D800 00832026 2402001C 2403002C 0064100A 3C03BF81 8C66F220
8C64F220 3C030580 3463A053 7CC6D800 00C33026 24050040 7C84D800 24631000
10830006 00A6100A 00022FC3 00402021 00801021 03E00008 00A01821 24040064
00002821 00801021 03E00008 00A01821
End CFunction
'
CFunction scope
00000000
3C029D00 8C480094 27BDFF70 AFB40078 8D140000 8C430000 8C480098 001458C0
00141140 8C6A0000 01621021 AFB1006C 8D110000 3C081062 25084DD3 00026080
01480019 3C03BF81 004C1021 8C8C0000 8FA400B0 8C69F220 AFB20070 00004010
3C0A0661 8C920000 8FA400B4 7D29D800 354BA053 AFB30074 AFBF008C AFBE0088
AFB70084 AFB60080 AFB5007C AFB00068 8FAD00AC 2631FFFF 00084182 112B02B2
8C930000 8C64F220 254AA053 7C84D800 008A5026 2403001C 2404002C 008A180A
3C04BF81 8C8BF220 8C89F220 3C040580 3484A053 7D6BD800 01645826 240A0040
7D29D800 24841000 112402AC 014B180A 28630033 24090028 0143480A 8CAA0000
8CA40004 01441825 1060026E 00141840 00E3A821 AFA60024 00C31821 AFA70028
000A5027 00042027 ACAA0000 ACA40004 71884002 10000002 24100001 00808021
0050001B 020001F4 00002812 0105001B 00A001F4 0000B812 02E9282B 14A0FFF7
26040001 8FA200A8 8C470000 14E00264 2405FFFF 8DA80000 0008280B 00073823
7C073E20 19000265 AFA0001C 3C021000 3C0FBF88 ADE21064 2404FFFF 34028000
3C06BF81 3C18BF88 AF001068 AFA40020 ACC29004 3C04BF81 8C89F220 3C020661
7D29D800 3446A053 11260265 7C084620 8C86F220 2444A053 7CC6D800 00C43026
2402001C 2404002C 0086100A 3C04BF81 8C8AF220 8C86F220 3C040580 3484A053
7D4AD800 01445026 24090040 7CC6D800 24841000 10C40226 012A100A 28420033
10400223 3C040C00 3C02BF81 AC449040 3C02BF88 AC406118 3C02BF88 AC406108
3C04FFFF 3C02BF81 AC449050 24040200 3C02BF81 AC449020 24040007 3C02BF81
AC449010 340480E4 3C02BF81 AC449000 3C02BF81 34048000 AC449008 3C020008
ADE21064 3C16BF81 AF001068 8EC29010 7C4201C0 1040FFFD 00000000 3C0ABF81
3C09BF81 8D429070 8D229080 8EC29010 30420080 1440FFFD 3C0DBF81 0290001B
020001F4 3C0BBF81 8DA490F0 8D649100 8D469070 8D249080 24C60001 24840001
A4660000 A6A40000 0000A012 40824800 12800230 00003021 0000F021 00007021
3C0C9D00 8EC29010 7C4201C0 1040FFFD 00000000 40024800 0057001B 02E001F4
00002012 03C4102B 1040000A 00000000 8D449070 8D229080 10A0019A 001EC840
0079F821 02B9C821 A7E40000 27DE0001 A7220000 8EC29010 30420080 1440FFFD
00000000 40024800 0057001B 02E001F4 00002012 03C4102B 1040000B 03D4102B
8DA490F0 8D629100 10A0013E 001EC840 0079F821 02B9C821 A7E40000 27DE0001
A7220000 03D4102B 1440FFD6 3C04004C 24844B40 00C4302B 3C041000 ADE41064
3C020008 34048000 3C05BF81 AF001068 ACA49004 ADE21064 AF021068 10C001F1
3C029D00 8C420098 8C560000 3C028888 34428889 02C20019 8FA200A0 0000B010
8C470000 0016B1C2 0016B180 04E00063 0016B843 2E820002 14400060 8FA80024
240B0001 AFB50024 AFB0001C AFB3002C 0000F021 3C0A9D00 24023057 01608021
01009821 0060A821 10000003 AFB40020 8FA400A0 8C870000 86650002 86680000
70A22802 71024002 00B2001B 024001F4 8FA6001C 24030001 240400FF AFA40014
AFA30010 8D430050 03C0A021 03C6F021 02802021 03C03021 AFA20030 AFAA0060
26100001 26730002 00002812 0112001B 024001F4 00B72821 00004012 01174021
0116001B 02C001F4 00004812 00B6001B 02C001F4 02292823 00A72823 00004012
02284023 0060F809 01073823 86A50002 8FA20030 86A80000 70A22802 71024002
00B2001B 024001F4 8FA300A0 3C0600FF 8FAA0060 24040001 34C6FFFF 8C670000
AFA40010 AFA60014 8D430050 02802021 03C03021 26B50002 00002812 0112001B
024001F4 00B72821 00004012 01174021 0116001B 02C001F4 00004012 00B6001B
02C001F4 02282823 00A72823 00004812 02294823 0060F809 01273823 8FA30020
8FA20030 1603FFB2 8FAA0060 8FB50024 8FB0001C 8FB3002C 8FB40020 8FA500A4
8CA70000 04E0005B 2E820002 14400059 8FA20028 24030001 AFB00018 AFB4001C
00009021 3C099D00 241E3057 00608021 10000003 0040A021 8FA300A4 8C670000
86850002 86880000 70BE2802 711E4002 00B3001B 026001F4 8FA40018 24020001
240300FF AFA20010 AFA30014 02401021 8D230050 02449021 02403021 00402021
AFA20030 AFA9005C 26100001 26940002 00002812 0113001B 026001F4 00B72821
00004012 01174021 0116001B 02C001F4 00005012 00B6001B 02C001F4 022A2823
00A72823 00004012 02284023 0060F809 01073823 86A80002 86A50000 711E4002
70BE2802 0113001B 026001F4 8FA300A4 8FA20030 24040001 8C670000 AFA40010
00402021 3C0600FF 8FA9005C 34C6FFFF AFA60014 8D230050 02403021 26B50002
00004012 00B3001B 026001F4 01171021 00002812 00B72821 00B6001B 02C001F4
00002812 0056001B 02C001F4 02252823 00A72823 00001012 02221023 0060F809
00473823 8FA2001C 1602FFB3 8FA9005C 8FB00018 02009021 00009821 3C029D00
8C420098 8C420000 10400016 3C150080 00008021 3C149D00 24160001 36B58080
8E820094 02002821 8C460000 AFB60010 AFB50014 8E820050 02003821 00002021
0040F809 24C6FFFF 8E820098 8C420000 000218C2 02038021 0202102B 5440FFF1
8E820094 3C029D00 8C420094 8C460000 10C00018 3C160080 3C15CCCC 00008021
3C149D00 24170001 36D68080 36B5CCCD AFB70010 AFB60014 8E820050 02003021
02002021 00002821 0040F809 02203821 8E820094 8C460000 00D50019 00001010
000210C2 02028021 0206102B 5440FFF1 AFB70010 3C140080 36948080 24150001
3C109D00 AFB50010 AFB40014 8E020050 02202821 02203821 00002021 0040F809
24C6FFFF 8E020094 02203821 8C440000 AFB50010 AFB40014 8E020050 2484FFFF
00002821 0040F809 00803021 8FBF008C 02401021 02601821 8FBE0088 8FB70084
8FB60080 8FB5007C 8FB40078 8FB30074 8FB20070 8FB1006C 8FB00068 03E00008
27BD0090 10E00006 8FB9001C 1320006E 84790000 0327C82A 57200091 0087282B
5100000A A4640000 8FB90020 1320006D 86B90000 0328C82A 13200004 A4640000
0048F82B 0005C827 033F280A A6A20000 01C02021 40844800 8D820090 3C19004C
24C60001 80440017 37394B40 00D9102B 1080FEAC 0282F00A 8D820020 AFA30050
AFA50054 AFA60058 AFA70048 AFA8004C AFA9005C AFAA0060 AFAB0034 AFAC0044
AFAD0030 AFAE0040 AFAF003C 0040F809 AFB80038 8FA30050 8FA50054 8FA60058
8FA70048 8FA8004C 8FA9005C 8FAA0060 8FAB0034 8FAC0044 8FAD0030 8FAE0040
8FAF003C 1440FE8F 8FB80038 3C031000 ADE31064 3C020008 3C12004C 34038000
3C06BF81 AF001068 36524B40 ACC39004 00009821 ADE21064 AF021068 1000FF60
3C029D00 10E00006 8FB9001C 1320001F 84790000 0327C82A 5720004D 0087282B
5100000A A4640000 8FB90020 1320000C 86B90000 0328C82A 13200004 A4640000
0048F82B 0005C827 033F280A 01C02021 A6A20000 40844800 1000FE56 24C60001
0119C82A 1320FFF9 A4640000 0102F82B 0005C827 033F280A 01C02021 A6A20000
40844800 1000FE4B 24C60001 00F9C82A 1320FFE3 2419FFFF 00E4282B 0005C80B
1000FFDF 03202821 00F9C82A 1320FF94 2419FFFF 00E4282B 0005C80B 1000FF90
03202821 0119C82A 1320FF98 A4640000 0102F82B 0005C827 033F280A A6A20000
01C02021 40844800 8D820090 3C19004C 24C60001 80440017 37394B40 00D9102B
1080FE40 0282F00A 1000FF94 8D820020 3C040400 3C02BF81 AC449040 1000FDDD
3C02BF88 00E35821 00C31821 AFA30024 AFAB0028 00C01821 1000FD91 00E0A821
2419FFFF 0005C80B 1000FF6D 03202821 2419FFFF 0005C80B 1000FFB1 03202821
18E00037 2402FFFF 8DA80000 7C073E20 00002821 1D00FD9D AFA2001C 3C021000
3C0FBF88 ADE21064 3C06BF81 34028000 3C18BF88 AF001068 3C04BF81 ACC29004
8C89F220 3C020661 00084023 7D29D800 3446A053 7C084620 1526FD9D AFA00020
1000FDA2 2402002C 3C04BF81 8C8BF220 8C89F220 3C040580 3484A053 7D6BD800
01645826 2403002C 240A0040 7D29D800 24841000 1524FD56 014B180A 1000FD57
24090040 3C12004C 36524B40 1000FEDB 00009821 3C041000 ADE41064 3C020008
34048000 3C05BF81 AF001068 ACA49004 ADE21064 AF021068 1000FE02 3C029D00
8DA80000 1000FD65 00002821
End CFunction



For those interested here is the revised C source:



long long scope(long long *microsecondsperdivision, long long *toggle, short *channel0, short *channel1, long *c0pos, long *c1pos, long *c0trig, long *c1trig, long *mpv0, long *mpv1){
unsigned int count=HRes,loop=0,k=VRes-1,divbasic=HRes*200,div,mps=*microsecondsperdivision,scale=1;
unsigned int cpu=CurrentCpuSpeed/1000,s0=*mpv0,s1=*mpv1, tickmax=40;
unsigned int current_ticks=0,ticktest=0,triggered=0,currentc0,currentc1, triggertimeout=0;
short c0dir=0,c1dir=0,c0lev=0,c1lev=0;
short *c1;
short *c0;
short *c1last;
short *c0last;
if(NBRPINS>50) tickmax=64;
if(*toggle){ //decide which buffer to use
c1=channel1+HRes;
c0=channel0+HRes;
c1last=channel1;
c0last=channel0;
} else {
c1=channel1;
c0=channel0;
c1last=channel1+HRes;
c0last=channel0+HRes;
}
*toggle=~(*toggle); //swap buffers for next time

while(ticktest<tickmax){ //implement scaling if display resolution too high for the ADC
div=divbasic/scale;
ticktest=cpu*mps/div;
scale++;
}
scale--;

if (*c0trig==0 && *c1trig==0)triggered=~triggered; //no trigger specified so free run
if(*c0trig>0){
c0lev=*c0trig;
c0dir=~c0dir;
} else {
c0lev=-(*c0trig);
}
if(*c1trig>0){
c1lev=*c1trig;
c1dir=~c1dir;
} else {
c1lev=-(*c1trig);
}

// configure and enable the ADC
CloseADC10();// ensure the ADC is off before setting the configuration
// define setup parameters for OpenADC10
#define PARAM1 ADC_MODULE_ON | ADC_FORMAT_INTG | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON
#define PARAM2 ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_OFF| ADC_SAMPLES_PER_INT_2 | ADC_ALT_BUF_ON | ADC_ALT_INPUT_ON
#define PARAM3 ADC_CONV_CLK_SYSTEM | ADC_SAMPLE_TIME_2
#define PARAM5 SKIP_SCAN_ALL
#define PARAM4 0
#define maxwait 5000000 //wait for 5,000,000 samples before timing out if no trigger
// configure to sample relevant ADC channels by chip type
if(NBRPINS>50) {
SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF | ADC_CH0_POS_SAMPLEA_AN0 |ADC_CH0_NEG_SAMPLEB_NVREF | ADC_CH0_POS_SAMPLEB_AN4);
} else {
SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF | ADC_CH0_POS_SAMPLEA_AN0 |ADC_CH0_NEG_SAMPLEB_NVREF | ADC_CH0_POS_SAMPLEB_AN12);
}
// configure ADC and enable it
OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 );
// Now enable the ADC logic
EnableADC10();
// the results of the conversions are available in channel4 and channel5
mT4IntEnable(0); // disable interrupt

while (~ReadActiveBufferADC10() & 1); //wait for first conversions to complete
currentc0=ReadADC10(0);
currentc1=ReadADC10(1);
while (ReadActiveBufferADC10()); //wait for first conversions to complete
currentc0=ReadADC10(8);
currentc1=ReadADC10(9);
c0[0]=(ReadADC10(0)+1);
c1[0]=(ReadADC10(1)+1);
count = count / scale;
asm volatile("mtc0 %0, $9": "+r"(current_ticks)); //set the current number of ticks to 0
while(loop<count)
{
while (~ReadActiveBufferADC10() & 1); //wait for next conversion to complete

asm volatile("mfc0 %0, $9" : "=r"(current_ticks));//get the time in ticks since zeroed
if(current_ticks/ticktest>loop){ //save if I'm into the next time period
currentc0=(ReadADC10(0));
currentc1=(ReadADC10(1));
if(triggered){
c0[loop] = currentc0;
c1[loop++] = currentc1;
} else{
if (c0lev) {
if (c0dir) {
if (c0[0] < c0lev && currentc0 >= c0lev) triggered = ~triggered;
} else {
if (c0[0] > c0lev && currentc0 <= c0lev) triggered = ~triggered;
}
}
if (c1lev) {
if (c1dir) {
if (c1[0] < c1lev && currentc1 >= c1lev) triggered = ~triggered;
} else {
if (c1[0] > c1lev && currentc1 <= c1lev) triggered = ~triggered;
}
}
c0[0] = currentc0;
c1[0] = currentc1;
current_ticks=0;
asm volatile("mtc0 %0, $9": "+r"(current_ticks)); //set the current number of ticks to 0
triggertimeout++;
}
}
while (ReadActiveBufferADC10()); //wait for next conversion to complete
//while(count--)
asm volatile("mfc0 %0, $9" : "=r"(current_ticks));//get the time in ticks since zeroed
if(current_ticks/ticktest>loop){ //save if I'm into the next time period
currentc0=(ReadADC10(8));
currentc1=(ReadADC10(9));
if(triggered){
c0[loop] = currentc0;
c1[loop++] = currentc1;
} else{
if (c0lev) {
if (c0dir) {
if (c0[0] < c0lev && currentc0 >= c0lev) triggered = ~triggered;
} else {
if (c0[0] > c0lev && currentc0 <= c0lev) triggered = ~triggered;
}
}
if (c1lev) {
if (c1dir) {
if (c1[0] < c1lev && currentc1 >= c1lev) triggered = ~triggered;
} else {
if (c1[0] > c1lev && currentc1 <= c1lev) triggered = ~triggered;
}
}
c0[0] = currentc0;
c1[0] = currentc1;
current_ticks=0;
asm volatile("mtc0 %0, $9": "+r"(current_ticks)); //set the current number of ticks to 0
triggertimeout++;
if(triggertimeout>=maxwait)loop=count; //if not triggered at timeout exit the loop
if(Option->TOUCH_IRQ){
if(!PinRead(Option->TOUCH_IRQ)){
loop=count;
triggertimeout=maxwait;
}
}
}
}
}

CloseADC10();
mT4IntEnable(1);
if(triggertimeout<maxwait){
int s2=(VRes/240)*64,s3=s2/2;
if (*c0pos >= 0) {
for (loop = 1; loop < count; ++loop) {
DrawLine((loop - 1) * scale, k - ((unsigned int)c0last[loop - 1] * 12375 / s0 + s3) / s2 - *c0pos, loop * scale, k - ((unsigned int) c0last[loop] * 12375 / s0 + s3) / s2 - *c0pos, 1, 0xFF);
DrawLine((loop - 1) * scale, k - ((unsigned int)c0[loop - 1] * 12375 / s0 + s3) / s2 - *c0pos, loop * scale, k - ((unsigned int)c0[loop] * 12375 / s0 + s3) / s2 - *c0pos, 1, 0xFFFFFF);
}
}
if (*c1pos >= 0) {
for (loop = 1; loop < count; ++loop) {
DrawLine((loop - 1) * scale, k - ((unsigned int)c1last[loop - 1] * 12375 / s1 + s3) / s2 - *c1pos, loop * scale, k - ((unsigned int)c1last[loop] * 12375 / s1 + s3) / s2 - *c1pos, 1, 0xFF);
DrawLine((loop - 1) * scale, k - ((unsigned int)c1[loop - 1] * 12375 / s1 + s3) / s2 - *c1pos, loop * scale, k - ((unsigned int)c1[loop] * 12375 / s1 + s3) / s2 - *c1pos, 1, 0xFFFFFF);
}
}
} else {
scale=maxwait;
}

for(loop=0;loop<VRes;loop+=VRes/8)DrawLine(0,loop,HRes-1,loop,1,0x808080);
for(loop=0;loop<HRes;loop+=HRes/10)DrawLine(loop,0,loop,k,1,0x808080);
DrawLine(0,k,HRes-1,k,1,0x808080);
DrawLine(HRes-1,0,HRes-1,k,1,0x808080);
return scale;
}
Edited by matherp 2015-10-28
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 10:03pm 27 Oct 2015
Copy link to clipboard 

Hi Peter
Is there anything special about using pin 2 as one of the inputs as I use this pin on the 28 pin 170 as the touch screen interrupt.
I would like to use pins 24 and 23.
Cliff
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 10:09pm 27 Oct 2015
Copy link to clipboard 

  Quote  Is there anything special about using pin 2 as one of the inputs


I just chose pins with no alternate functions. The pin numbers have to be hardwired in the Cfunction because analogue commands works on AN0-AN15 references and these don't map easily onto pins or ports and I don't have access to any sort of lookup for them inside a CFunction.

You can easily recompile for pin 24 which would be AN11 rather than AN0 in the code line:

SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF | ADC_CH0_POS_SAMPLEA_AN0 |ADC_CH0_NEG_SAMPLEB_NVREF | ADC_CH0_POS_SAMPLEB_AN12);
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 10:38pm 27 Oct 2015
Copy link to clipboard 

Thanks Peter
But I am afraid the word recompile is out of my league.
I will cut tracks on my board and hardwire pin as the input.
Cliff
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 11:30pm 27 Oct 2015
Copy link to clipboard 

  Quote  I will cut tracks on my board and hardwire pin as the input.


Custom version sent by PM
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 11:57pm 27 Oct 2015
Copy link to clipboard 

Many thanks I will do some cutting and pasting.
Cliff
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 08:12am 28 Oct 2015
Copy link to clipboard 

BUG ALERT

In making the code run with both the SSD1963 and ILI9341 the display has to be scaled. The idea was that the absolute amplitude in pixels on the ILI9341 should be half the SSD1963 (240 pixels vertically vs 480). Unfortunately the code did the opposite

Here is the corrected Cfunction. Cliff: I'll PM you the version you need


CFunction scope
00000000
3C029D00 8C480094 27BDFF70 AFB40078 8D140000 8C430000 8C480098 001458C0
00141140 8C6A0000 01621021 AFB1006C 8D110000 3C081062 25084DD3 00026080
01480019 3C03BF81 004C1021 8C8C0000 8FA400B0 8C69F220 AFB20070 00004010
3C0A0661 8C920000 8FA400B4 7D29D800 354BA053 AFB30074 AFBF008C AFBE0088
AFB70084 AFB60080 AFB5007C AFB00068 8FAD00AC 2631FFFF 00084182 112B02B5
8C930000 8C64F220 254AA053 7C84D800 008A5026 2403001C 2404002C 008A180A
3C04BF81 8C8BF220 8C89F220 3C040580 3484A053 7D6BD800 01645826 240A0040
7D29D800 24841000 112402AF 014B180A 28630033 24090028 0143480A 8CAA0000
8CA40004 01441825 10600271 00141840 00E3A821 AFA60024 00C31821 AFA70028
000A5027 00042027 ACAA0000 ACA40004 71884002 10000002 24100001 00808021
0050001B 020001F4 00002812 0105001B 00A001F4 0000B812 02E9282B 14A0FFF7
26040001 8FA200A8 8C470000 14E00267 2405FFFF 8DA80000 0008280B 00073823
7C073E20 19000268 AFA0001C 3C021000 3C0FBF88 ADE21064 2404FFFF 34028000
3C06BF81 3C18BF88 AF001068 AFA40020 ACC29004 3C04BF81 8C89F220 3C020661
7D29D800 3446A053 11260268 7C084620 8C86F220 2444A053 7CC6D800 00C43026
2402001C 2404002C 0086100A 3C04BF81 8C8AF220 8C86F220 3C040580 3484A053
7D4AD800 01445026 24090040 7CC6D800 24841000 10C40229 012A100A 28420033
10400226 3C040C00 3C02BF81 AC449040 3C02BF88 AC406118 3C02BF88 AC406108
3C04FFFF 3C02BF81 AC449050 24040200 3C02BF81 AC449020 24040007 3C02BF81
AC449010 340480E4 3C02BF81 AC449000 3C02BF81 34048000 AC449008 3C020008
ADE21064 3C16BF81 AF001068 8EC29010 7C4201C0 1040FFFD 00000000 3C0ABF81
3C09BF81 8D429070 8D229080 8EC29010 30420080 1440FFFD 3C0DBF81 0290001B
020001F4 3C0BBF81 8DA490F0 8D649100 8D469070 8D249080 24C60001 24840001
A4660000 A6A40000 0000A012 40824800 12800233 00003021 0000F021 00007021
3C0C9D00 8EC29010 7C4201C0 1040FFFD 00000000 40024800 0057001B 02E001F4
00002012 03C4102B 1040000A 00000000 8D449070 8D229080 10A0019D 001EC840
0079F821 02B9C821 A7E40000 27DE0001 A7220000 8EC29010 30420080 1440FFFD
00000000 40024800 0057001B 02E001F4 00002012 03C4102B 1040000B 03D4102B
8DA490F0 8D629100 10A00141 001EC840 0079F821 02B9C821 A7E40000 27DE0001
A7220000 03D4102B 1440FFD6 3C04004C 24844B40 00C4302B 3C041000 ADE41064
3C020008 34048000 3C05BF81 AF001068 ACA49004 ADE21064 AF021068 10C001F4
3C029D00 8C420098 24160080 8C440000 3C028888 34428889 00820019 00001010
000211C2 02C2001B 004001F4 8FA200A0 8C470000 0000B012 04E00063 0016B843
2E820002 14400060 8FA80024 240B0001 AFB50024 AFB0001C AFB3002C 0000F021
3C0A9D00 24023057 01608021 01009821 0060A821 10000003 AFB40020 8FA400A0
8C870000 86650002 86680000 70A22802 71024002 00B2001B 024001F4 8FA6001C
24030001 240400FF AFA40014 AFA30010 8D430050 03C0A021 03C6F021 02802021
03C03021 AFA20030 AFAA0060 26100001 26730002 00002812 0112001B 024001F4
00B72821 00004012 01174021 0116001B 02C001F4 00004812 00B6001B 02C001F4
02292823 00A72823 00004012 02284023 0060F809 01073823 86A50002 8FA20030
86A80000 70A22802 71024002 00B2001B 024001F4 8FA300A0 3C0600FF 8FAA0060
24040001 34C6FFFF 8C670000 AFA40010 AFA60014 8D430050 02802021 03C03021
26B50002 00002812 0112001B 024001F4 00B72821 00004012 01174021 0116001B
02C001F4 00004012 00B6001B 02C001F4 02282823 00A72823 00004812 02294823
0060F809 01273823 8FA30020 8FA20030 1603FFB2 8FAA0060 8FB50024 8FB0001C
8FB3002C 8FB40020 8FA500A4 8CA70000 04E0005B 2E820002 14400059 8FA20028
24030001 AFB00018 AFB4001C 00009021 3C099D00 241E3057 00608021 10000003
0040A021 8FA300A4 8C670000 86850002 86880000 70BE2802 711E4002 00B3001B
026001F4 8FA40018 24020001 240300FF AFA20010 AFA30014 02401021 8D230050
02449021 02403021 00402021 AFA20030 AFA9005C 26100001 26940002 00002812
0113001B 026001F4 00B72821 00004012 01174021 0116001B 02C001F4 00005012
00B6001B 02C001F4 022A2823 00A72823 00004012 02284023 0060F809 01073823
86A80002 86A50000 711E4002 70BE2802 0113001B 026001F4 8FA300A4 8FA20030
24040001 8C670000 AFA40010 00402021 3C0600FF 8FA9005C 34C6FFFF AFA60014
8D230050 02403021 26B50002 00004012 00B3001B 026001F4 01171021 00002812
00B72821 00B6001B 02C001F4 00002812 0056001B 02C001F4 02252823 00A72823
00001012 02221023 0060F809 00473823 8FA2001C 1602FFB3 8FA9005C 8FB00018
02009021 00009821 3C029D00 8C420098 8C420000 10400016 3C150080 00008021
3C149D00 24160001 36B58080 8E820094 02002821 8C460000 AFB60010 AFB50014
8E820050 02003821 00002021 0040F809 24C6FFFF 8E820098 8C420000 000218C2
02038021 0202102B 5440FFF1 8E820094 3C029D00 8C420094 8C460000 10C00018
3C160080 3C15CCCC 00008021 3C149D00 24170001 36D68080 36B5CCCD AFB70010
AFB60014 8E820050 02003021 02002021 00002821 0040F809 02203821 8E820094
8C460000 00D50019 00001010 000210C2 02028021 0206102B 5440FFF1 AFB70010
3C140080 36948080 24150001 3C109D00 AFB50010 AFB40014 8E020050 02202821
02203821 00002021 0040F809 24C6FFFF 8E020094 02203821 8C440000 AFB50010
AFB40014 8E020050 2484FFFF 00002821 0040F809 00803021 8FBF008C 02401021
02601821 8FBE0088 8FB70084 8FB60080 8FB5007C 8FB40078 8FB30074 8FB20070
8FB1006C 8FB00068 03E00008 27BD0090 10E00006 8FB9001C 1320006E 84790000
0327C82A 57200091 0087282B 5100000A A4640000 8FB90020 1320006D 86B90000
0328C82A 13200004 A4640000 0048F82B 0005C827 033F280A A6A20000 01C02021
40844800 8D820090 3C19004C 24C60001 80440017 37394B40 00D9102B 1080FEA9
0282F00A 8D820020 AFA30050 AFA50054 AFA60058 AFA70048 AFA8004C AFA9005C
AFAA0060 AFAB0034 AFAC0044 AFAD0030 AFAE0040 AFAF003C 0040F809 AFB80038
8FA30050 8FA50054 8FA60058 8FA70048 8FA8004C 8FA9005C 8FAA0060 8FAB0034
8FAC0044 8FAD0030 8FAE0040 8FAF003C 1440FE8C 8FB80038 3C031000 ADE31064
3C020008 3C12004C 34038000 3C06BF81 AF001068 36524B40 ACC39004 00009821
ADE21064 AF021068 1000FF60 3C029D00 10E00006 8FB9001C 1320001F 84790000
0327C82A 5720004D 0087282B 5100000A A4640000 8FB90020 1320000C 86B90000
0328C82A 13200004 A4640000 0048F82B 0005C827 033F280A 01C02021 A6A20000
40844800 1000FE53 24C60001 0119C82A 1320FFF9 A4640000 0102F82B 0005C827
033F280A 01C02021 A6A20000 40844800 1000FE48 24C60001 00F9C82A 1320FFE3
2419FFFF 00E4282B 0005C80B 1000FFDF 03202821 00F9C82A 1320FF94 2419FFFF
00E4282B 0005C80B 1000FF90 03202821 0119C82A 1320FF98 A4640000 0102F82B
0005C827 033F280A A6A20000 01C02021 40844800 8D820090 3C19004C 24C60001
80440017 37394B40 00D9102B 1080FE3D 0282F00A 1000FF94 8D820020 3C040400
3C02BF81 AC449040 1000FDDA 3C02BF88 00E35821 00C31821 AFA30024 AFAB0028
00C01821 1000FD8E 00E0A821 2419FFFF 0005C80B 1000FF6D 03202821 2419FFFF
0005C80B 1000FFB1 03202821 18E00037 2402FFFF 8DA80000 7C073E20 00002821
1D00FD9A AFA2001C 3C021000 3C0FBF88 ADE21064 3C06BF81 34028000 3C18BF88
AF001068 3C04BF81 ACC29004 8C89F220 3C020661 00084023 7D29D800 3446A053
7C084620 1526FD9A AFA00020 1000FD9F 2402002C 3C04BF81 8C8BF220 8C89F220
3C040580 3484A053 7D6BD800 01645826 2403002C 240A0040 7D29D800 24841000
1524FD53 014B180A 1000FD54 24090040 3C12004C 36524B40 1000FEDB 00009821
3C041000 ADE41064 3C020008 34048000 3C05BF81 AF001068 ACA49004 ADE21064
AF021068 1000FDFF 3C029D00 8DA80000 1000FD62 00002821
End CFunction
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 10:40pm 28 Oct 2015
Copy link to clipboard 

Zonker has pointed out that the erase of the previous trace does not occur if you change the microseconds-per-division, offset or the scale. To do this the Cfunction would need to know the offset and scale of the last write as well as of the new write and I've run out of allowable parameters to the CFunction.

To get round this I've implemented a minor change as follows:

To remove a trace without writing a new one, call "scope" with exactly the same parameters as the last call but with the microsecondsperdivision negated. This will just remove the previous trace. You can then call scope again with the new parameters (including possibly a new positive microsecondsperdivision) and this will start the writing process again:

Pseudocode:
[code]
do
do while no change in parameters
i= scope(microsecondsperdivision,toggle,channel1buff(),channel2buff(),y1pos, y2pos, c1trig, c2trig ,c1mvperdivision,c2mvperdivision)
loop
' erase last trace
i= scope(-microsecondsperdivision,toggle,channel1buff(),channel2buff(),y1pos, y2pos, c1trig, c2trig ,c1mvperdivision,c2mvperdivision)
update parameters
loop
[/code]

New CFunction to implement this is:


CFunction scope
00000000
3C029D00 8C480094 27BDFF70 8C430000 AFB40078 8D140000 8C480098 8C6A0000
AFB1006C 8D110000 3C081062 25084DD3 01480019 001458C0 00141140 01621021
00004010 00026080 3C03BF81 004C1021 00086182 8FA800B0 8C69F220 AFB20070
3C0A0661 8D120000 8FA800B4 7D29D800 354BA053 AFB30074 AFBF008C AFBE0088
AFB70084 AFB60080 AFB5007C AFB00068 8FAD00AC 2631FFFF 112B02BA 8D130000
8C63F220 254AA053 7C63D800 006A5026 2409001C 2403002C 006A480A 3C03BF81
8C6BF220 3C0A0580 8C68F220 354AA053 7D6BD800 016A5826 24030040 7D08D800
254A1000 110A02A0 006B480A 29280033 24090028 0068480A 8C880004 0500029E
8C830000 24040001 AFA40020 8CAA0000 8CA40004 01444025 11000205 0014F040
00144040 00E85821 AFAB0018 00C84021 AFA6002C AFA70030 000A5027 00042027
ACAA0000 ACA40004 706C1802 10000002 24100001 00808021 0050001B 020001F4
00002812 0065001B 00A001F4 0000B012 02C9282B 14A0FFF7 26040001 8FA200A8
8C460000 14C000AA 241EFFFF 8DA70000 0007F00B 00063023 7C063620 18E000AB
AFA00024 8FA40020 2403FFFF 7C073E20 108000AB AFA30028 3C021000 3C19BF88
AF221064 3C05BF88 34028000 3C0BBF81 ACA01068 3C03BF81 AD629004 8C65F220
3C020661 7CA5D800 3444A053 50A40008 2402002C 8C64F220 2443A053 7C84D800
00832026 2402001C 2403002C 0064100A 3C03BF81 8C69F220 8C64F220 3C030580
3463A053 7D29D800 01234826 24050040 7C84D800 24631000 10830254 00A9100A
28420033 10400251 3C030C00 3C02BF81 AC439040 3C02BF88 AC406118 3C02BF88
AC406108 3C03FFFF 3C02BF81 AC439050 24030200 3C02BF81 AC439020 24030007
3C02BF81 AC439010 340380E4 3C02BF81 AC439000 3C02BF81 34038000 AC439008
3C0DBF88 3C020008 AF221064 3C15BF81 ADA01068 8EA29010 7C4201C0 1040FFFD
3C0ABF81 3C09BF81 8D429070 8D229080 8EA29010 30420080 1440FFFD 3C0DBF81
0290001B 020001F4 3C0CBF81 8DA490F0 8D849100 8D459070 8D249080 24A50001
A5050000 8FA50018 24840001 A4A40000 00001812 0000A012 40824800 1280022B
00002821 0000B821 00007021 3C0B9D00 8EA29010 7C4201C0 1040FFFD 00000000
40024800 0056001B 02C001F4 00007812 02EF102B 1040000B 00000000 8D449070
8D229080 13C00179 8FBF0018 00177840 010FC021 03EF7821 A7040000 26F70001
A5E20000 8EA29010 30420080 1440FFFD 00000000 40024800 0056001B 02C001F4
0000C012 02F8102B 1040000C 02E3102B 8DA490F0 8D829100 13C0017F 8FBF0018
00177840 010FC021 03EF7821 A7040000 26F70001 A5E20000 02E3102B 1440FFD4
00000000 3C03004C 24634B40 00A3282B 3C031000 AF231064 3C020008 3C1FBF88
34038000 3C04BF81 AFE01068 AC839004 AF221064 AFE21068 14A00012 3C029D00
3C12004C 36524B40 100000E8 00009821 18C001F3 2402FFFF 8DA70000 7C063620
0000F021 1CE0FF57 AFA20024 8FA40020 00073823 7C073E20 1480FF57 AFA00028
3C029D00 8C420098 24150080 8C430000 3C028888 34428889 00620019 00001010
000211C2 02A2001B 004001F4 8FA200A0 8C4B0000 0000A812 05600065 0015B043
2E820002 14400062 24020001 8FBE002C AFB00028 AFB3002C 0000B821 3C0A9D00
24033057 AFB40024 00409821 10000006 01008021 8FA20024 12620052 26100002
8FA400A0 8C8B0000 87C70002 87C50000 70E33802 70A32802 00F2001B 024001F4
24020001 AFA20010 8FA40028 240200FF AFA20014 8D420050 02E0A021 02E4B821
AFA30060 AFAA005C 02802021 02E03021 26730001 27DE0002 00003812 00B2001B
024001F4 00F63821 00002812 00B62821 00B5001B 02A001F4 00002812 00F5001B
02A001F4 02252823 00AB2823 00003812 02273823 0040F809 00EB3823 8FA20020
8FA30060 1040FFD3 8FAA005C 86050002 86080000 70A32802 71034002 00B2001B
024001F4 8FA200A0 3C0B00FF 24040001 356BFFFF 8C470000 AFA40010 AFAB0014
8D420050 02802021 02E03021 26100002 00002812 0112001B 024001F4 00B62821
00004012 01164021 0115001B 02A001F4 00004012 00B5001B 02A001F4 02282823
00A72823 00004812 02294823 0040F809 01273823 8FA20024 8FAA005C 1662FFB0
8FA30060 8FB40024 8FB3002C 8FB00028 8FA500A4 8CAB0000 05600061 2E820002
1440005F 8FA30018 AFB4001C 8FB70030 00009021 241E0001 3C099D00 24023057
0060A021 10000006 AFB00018 8FA3001C 13C30052 26940002 8FA400A4 8C8B0000
86E70002 86E50000 70E23802 70A22802 00F3001B 026001F4 24030001 AFA30010
8FA40018 240300FF AFA30014 8D230050 02408021 02449021 AFA20034 AFA90058
02002021 02403021 27DE0001 26F70002 00003812 00B3001B 026001F4 00F63821
00002812 00B62821 00B5001B 02A001F4 00002812 00F5001B 02A001F4 02252823
00AB2823 00003812 02273823 0060F809 00EB3823 8FA30020 8FA20034 1060FFD3
8FA90058 86850002 86880000 70A22802 71024002 00B3001B 026001F4 8FA300A4
3C0B00FF 24040001 356BFFFF 8C670000 AFA40010 AFAB0014 8D230050 02002021
02403021 26940002 00002812 0113001B 026001F4 00B62821 00004012 01164021
0115001B 02A001F4 00005012 00B5001B 02A001F4 022A2823 00A72823 00004012
02284023 0060F809 01073823 8FA3001C 8FA90058 17C3FFB0 8FA20034 8FB00018
02009021 00009821 3C029D00 8C420098 8C420000 10400016 3C150080 00008021
3C149D00 24160001 36B58080 8E820094 02002821 8C460000 AFB60010 AFB50014
8E820050 02003821 00002021 0040F809 24C6FFFF 8E820098 8C420000 000218C2
02038021 0202102B 5440FFF1 8E820094 3C029D00 8C420094 8C460000 10C00018
3C160080 3C15CCCC 00008021 3C149D00 24170001 36D68080 36B5CCCD AFB70010
AFB60014 8E820050 02003021 02002021 00002821 0040F809 02203821 8E820094
8C460000 00D50019 00001010 000210C2 02028021 0206102B 5440FFF1 AFB70010
3C140080 36948080 24150001 3C109D00 AFB50010 AFB40014 8E020050 02202821
02203821 00002021 0040F809 24C6FFFF 8E020094 02203821 8C440000 AFB50010
AFB40014 8E020050 2484FFFF 00002821 0040F809 00803021 8FBF008C 02401021
02601821 8FBE0088 8FB70084 8FB60080 8FB5007C 8FB40078 8FB30074 8FB20070
8FB1006C 8FB00068 03E00008 27BD0090 00FE7821 00DEF021 AFAF0030 AFBE002C
00C04021 1000FDFC AFA70018 10C00006 8FAF0024 11E0006E 850F0000 01E6782A
55E00096 0086F02B 10E0000D 8FAF0018 8FAF0028 11E00058 8FBF0018 8FB80018
870F0000 01E7782A 11E00005 8FAF0018 0047C02B 001E7827 01F8F00A 8FAF0018
A5040000 01C02021 A5E20000 40844800 1000FE74 24A50001 10C00006 8FAF0024
11E0005A 850F0000 01E6782A 55E00077 0086F02B 10E0000A 8FAF0018 8FAF0028
11E00059 8FBF0018 8FB80018 870F0000 01E7782A 15E0006A 0047C02B 8FAF0018
A5040000 A5E20000 01C02021 40844800 8D620090 3C18004C 24A50001 80440017
37184B40 00B8102B 1080FE6B 0062B80A 8D620020 AFA30060 AFA50054 AFA60048
AFA7004C AFA80050 AFA90058 AFAA005C AFAB0044 AFAC0038 AFAD0034 AFAE0040
0040F809 AFB9003C 8FA30060 8FA50054 8FA60048 8FA7004C 8FA80050 8FA90058
8FAA005C 8FAB0044 8FAC0038 8FAD0034 8FAE0040 1440FE50 8FB9003C 3C031000
AF231064 3C020008 3C08BF88 3C12004C 34038000 3C0BBF81 AD001068 36524B40
AD639004 00009821 AF221064 AD021068 1000FF3E 3C029D00 87EF0000 00EF782A
11E0FFAF 8FAF0018 00E2C02B 001E7827 01F8F00A 8FAF0018 A5040000 01C02021
A5E20000 40844800 1000FE1E 24A50001 00CF782A 11E0FF94 241FFFFF 00C4F02B
001EF80B 1000FF90 03E0F021 00CF782A 11E0FFA8 241FFFFF 00C4F02B 001EF80B
1000FFA4 03E0F021 87EF0000 00EF782A 11E0FFAB 8FAF0018 00E2C02B 001E7827
1000FFA6 01F8F00A 8C880004 24090040 0501FD64 8C830000 00031823 1000FD63
AFA00020 1000FD4D 2409002C 3C030400 3C02BF81 AC439040 1000FDAF 3C02BF88
001E7827 1000FF95 01F8F00A 2418FFFF 001EC00B 1000FF87 0300F021 2418FFFF
001EC00B 1000FF68 0300F021 3C031000 AF231064 3C03BF88 AC601068 3C020008
34038000 3C04BF81 3C05BF88 AC839004 AF221064 ACA21068 1000FE1A 3C029D00
8DA70000 1000FD63 0000F021
End CFunction



 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 708
Posted: 07:02pm 29 Oct 2015
Copy link to clipboard 

Evening Gent's

Ok... I've updated the CFunction code and attached an update...

During testing, I noticed a few things. The Cfunction does indeed perform properly, at least the parts I can test so far. I do not have anything connected to the input channels yet... But, I just happen to be going to visit the eye doc tomorrow, so I get the rest of the day off work... (sweet) So, will be doing the hardware add-on's...

Playing with the "change position" spin boxes works correctly but the "refresh" seems to be slower than the pen_down INT's coming from the spinbox if you hold down the arrow buttons... So far, this doesn't seem to cause any problems, as I think the MM Basic core doesn't allow more that one INT request to happen at a time... (single nested)

It does however seem to slow down the repeat speed by half (or so)...
No big deal so far.. (not a show stopper)

The other thing I noticed while playing with the channel POS spin boxes...

If you move Channel 1 trace to POS 359 OR move Channel 2 trace to POS 299, The CFunction seems to get caught up trying to clear itself repeatedly...?

Not quite sure what is causing this yet... Will test more in the morning...

Anyway, Nuf babbling for now...

2015-10-30_050123_scope_gui_SSD1963_v2.zip

Thanks Pete for the update..! Edited by Zonker 2015-10-31
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 10:53pm 29 Oct 2015
Copy link to clipboard 

  Quote  If you move Channel 1 trace to POS 359 OR move Channel 2 trace to POS 299, The CFunction seems to get caught up trying to clear itself repeatedly...? ]


I can't replicate this and there is nothing in the logic that makes those number special in any way so any more info would be helpful.


I've cribbed/designed a simple variable gain AC/DC switchable analogue input stage and would appreciate comments from those with some real analogue experience - remember we only need 2MHz analogue bandwidth

2015-10-30_084857_analogueinput.pdf

The basic concepts come from here but I've added AC/DC coupling selection and variable gain on the opamp using a digital potentiometer. Total parts cost for dual channel should be less than $5
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 04:09am 09 Nov 2015
Copy link to clipboard 

I've now built up a two channel programmable-gain, programmable-coupling, input stage.




The vero layout is:




The schematic is attached:

2015-11-09_133021_input.pdf

The labelling on the vero design should be obvious:
Inputs are on H5 and H8

H6 is the Micromite connection:
DC1 select the channel 1 input coupling: low to AC, high to DC couple
Out1 is the channel 1 voltage output for input to the Micromite DAC
CS1 is the chip select for the channel 1 programmable gain
Out2 is the channel 2 voltage output for input to the Micromite DAC
SDO connects to SPI 1 OUT
SCK connects to SPI 1 CLK
CS2 is the chip select for the channel 2 programmable gain
DC2 select the channel 2 input coupling: low to AC, high to DC couple

To set up the amplifier, set DC1 and DC2 high, short out H5 and H8 and apply power to the board. Then adjust VR1 and VR2 until Out1 and Out2 are exactly half of the supply voltage.

The digital pots control the gain of the second stage of the opamp
Gain is given by the equation "G = 1 + DigitalPotResistance/500"

I use 10K digital pots (MCP4161) which power up at 50% setting giving a gain of approximately 11 which is then divided by the x10 attenuator.

Driving the 257 position MCP4161 digital pots is very easy:
SPI OPEN 1000000,3,16
pin(CS)=0
i=SPI(pot setting: 0-256)
pin(CS)=1

I'll put together a full Micromite program in the next days










Edited by matherp 2015-11-10
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 668
Posted: 12:39pm 09 Nov 2015
Copy link to clipboard 

Peter,

I am in absolute awe at the speed with which you can develop and implement projects. Thanks for sharing your ideas, circuits and code.

This is one I hope to have a go at in the new year.

Warmest Thanks,
Doug.

... all the Maximites, almost all of the MicromMites, all the MM Extremes, all the ArmMites, and loving it!
 
Lou

Senior Member

Joined: 01/02/2014
Location: United States
Posts: 211
Posted: 06:50pm 09 Nov 2015
Copy link to clipboard 

Thanks Peter,

A great project, I hope to build one on a Backpack when I get one of those round tuits in a couple months.
And thanks for posting the files on your Backpack board. Is the wiring bodge you refered to fixed in your new Backpack files ??

Lou
Microcontrollers - the other white meat
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2745
Posted: 09:49pm 09 Nov 2015
Copy link to clipboard 

  Lou said  . . . Is the wiring bodge you refered to fixed in your new Backpack files ??


According to Peter's other post , the answer is Yes!
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.org
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 10:01pm 09 Nov 2015
Copy link to clipboard 

UPDATE/ERRATA


The offset adjustment circuit works for DC coupling or AC coupling but needs to be set differently in the two cases - this needs more work
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 708
Posted: 04:31pm 11 Nov 2015
Copy link to clipboard 

Evening Gent's..

I wanted to let Peter know that I have not stopped playing with the scope C Function, even thou I took a a few days to check out the ESP8266

Currently, I am kind of stuck on a problem I can't seem to figure out...

I am running an Explore64 PCB with a 7" panel and it seems the the pen down INT stops working... I tried changing displays with no help... I don't have another working 64 board as somehow the USB stopped working on the #1 build... I tried going through the CAL again several times and it always works correctly. However the touch test does not draw anything on the screen.. Sometimes after CAL, things start working again for a bit... Am I missing something..? Do you need a pullup on the touch INT line..?

I traced through the wiring.. Seems OK.. It's just weird.. The program's timer puts the GUI objects away if you don't keep playing with them. The first time you touch the screen, (which works like a champ every time BTW), restores the objects that the user was last changing. After that, the program stops responding to pen down INT's.. It seems like it's working to well not to be working...

Oh, another question.. I wired the inputs with a simple resistor divider to scale inputs to the 10v scale and started feeding in some signals. I noticed that using just one channel input effects both traces on the display. The second channel seems to display the same signal but at about half the amplitude.. Not sure why this is...? Not sure what the j variable does.. maybe a channel select..?

Anyway, nuff for now... (more head scratching needed)
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 2964
Posted: 09:43pm 11 Nov 2015
Copy link to clipboard 

  Quote  The second channel seems to display the same signal but at about half the amplitude.


This is just cross-talk between adjacent pins - it goes away as soon as you put a real signal on the second channel.

Revised version of the input stage attached - needs more testing but looking good so far


2015-11-12_074204_inputstage.pdf



Edited by matherp 2015-11-13
 
Lou

Senior Member

Joined: 01/02/2014
Location: United States
Posts: 211
Posted: 12:56pm 16 Nov 2015
Copy link to clipboard 

Wizz wrote,

According to Peter's other post , the answer is Yes!

That post refers to the niggles, I was wondering about the wiring bodge !!

It's a great project, I hope to build one over the winter.

Lou
Microcontrollers - the other white meat
 
Emady
Newbie

Joined: 02/02/2016
Location: United Kingdom
Posts: 16
Posted: 05:08am 05 Apr 2016
Copy link to clipboard 

Good evening all,

I was wondering, how difficult would it be to add XY mode to this oscilloscope? I am considering building one to use as a spectrum analyser for my SA adaptor but that requires XY mode.

Thanks for you suggestions
Elia
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1577
Posted: 11:43pm 26 Aug 2016
Copy link to clipboard 

Hi Peter,

Can the software you used to create the vero layout for this produce a similar layout for Grogs expansion board for the E100?

Would be interested in building it on one & having a go at an interface.

Could be popular with novice users on a budget.

Even more so if the board could include your logic analyser.

I can probably work it out from the schematic; just not aware if the software can do the same as a very simple task for that type of layout.

Cheers

Phil.

  matherp said   I've now built up a two channel programmable-gain, programmable-coupling, input stage.




The vero layout is:




The schematic is attached:

2015-11-09_133021_input.pdf
 
     Page 1 of 2    
© JAQ Software 2019