using PC Scope to test a power adaptor from the mains grid.

i have been using “PC Scope” to 'scope some simple OpAmp/Oscillator circuits but now intend to measure some power adaptors which provide 5V at 2A.

FYI; it uses code running on an Arduino;

/*
  EFY PC OsciloScope
  Read A0 and send to UART at 115200.  

  Read the voltages as fast as possible and send to serial port.
  115200 baud pushes each byte at around 85us. 
  But the default ADC config by Arduino gives ADC at 116us. so here ADC config with additional lines of code and get samples faster than 85us.
  
  Data throughput is decided by the serial baud rate
  @ 115.2k baud we can get 12kSps
   
  Created on 18th Oct 2016
  by Balaji ramalingam, Robert Bosch, Banagalore
  Balajir@in.bosch.com
 
 */

// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin1 = A0;  // Analog input pin that the potentiometer is attached to
static int ctr,flag_tog;
static unsigned char adcval;

void setup()
{
  Serial.begin(115200);
  
  pinMode(13, OUTPUT);

  ADCSRA = 0;             // clear ADCSRA register
  ADCSRB = 0;             // clear ADCSRB register
  ADMUX |= (0 & 0x07);    // set A0 analog input pin
  ADMUX |= (1 << REFS0);  // set reference voltage
  ADMUX |= (1 << ADLAR);  // left align ADC value to 8 bits from ADCH register

  // sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
  // for Arduino Uno ADC clock is 16 MHz and a conversion takes 13 clock cycles
  //ADCSRA |= (1 << ADPS2) | (1 << ADPS0);    // 32 prescaler for 38.5 KHz
  ADCSRA |= (1 << ADPS2);                     // 16 prescaler for 76.9 KHz
  //ADCSRA |= (1 << ADPS1) | (1 << ADPS0);    // 8 prescaler for 153.8 KHz

  ADCSRA |= (1 << ADATE); // enable auto trigger
  ADCSRA |= (1 << ADIE);  // enable interrupts when measurement complete
  ADCSRA |= (1 << ADEN);  // enable ADC
  ADCSRA |= (1 << ADSC);  // start ADC measurements
}

ISR(ADC_vect)
{
  adcval = ADCH;  // read 8 bit value from ADC
}
  
void loop()
{
  Serial.write(adcval);
  
  // Following code to generate ref signal at pin 13 @ 50HZ. You can connect A0 to see the waveform in PCScope.exe
  ctr++;
  if(ctr>117) //117=10.03ms
  {
   ctr=0; 
   flag_tog = !flag_tog; 
   digitalWrite(13, flag_tog);
  }
}

and the circuit looks like this;

*without the voltage divider which i added to the original suggested circuit by ‘PC Scope’.

now, i am thinking that this 2A is a no-no to plug into the Arduino Uno, right ?

if so, is there some modification i can do to allow measuring of this 2A power supply - something like a current-limiting resistor perhaps ?

Two issues. 1) The sketch measures nothing. 2) The circuit is pretty usless for load testing an adapter.

You could use the Arduino to measure the adapter output voltage but that’s not testing - since there is no load on the adapter. The simplest way to test is to place a 2.5 ohm, 10 watt resistor across the 5v output. That will be a 2 amp load when the adapter outputs 5v. With a multimeter, measure the dc output voltage and then check the ac ripple. That’s testing it. You cannot easily test for the ac ripple with an Arduino without additional circuitry.

If this is something you need to do often, buy a usb in-line tester and load. They can be had for a few dollars on eBay.

Also, consider using the PC Scope on a Laptop running only on battery (i.e. charger disconnected). Whenever probing anything that is plugged into mains, the test instrument should be isolated. I've had "odd experiences" that would suggest that a PC [or at least the ones I've owned] is not always so isolated. I use my scope [not a PC Scope] with an isolation transformer [isolation on a budget!], whenever I probe anything that's plugged into the wall -- even if "only" by WallWart or other such "low" voltage supply. Also consider that the max input voltage may not be that high on a PC Scope, and the input protection may not be all that great -- read the manual. Also, consider using a 10:1 probe. That will afford a bit more protection.

Here's an excellent discussion on the subject: oscilloscope - How to attach (safely?) an o-scope to various sources - Electrical Engineering Stack Exchange

Also, in your sketch. I'm wondering what your reasoning is for using static in your global declarations? Truly, doing so will limit the scope to the current file [or translation unit], but is this really needed? I'm asking because I don't know -- and I'm perched to learn something new :wink:

avr_fred:
Two issues. 1) The sketch measures nothing.

there is still a PCscope.exe that actually plots the 'scope trace.
i suppose the sketch itself is just a 'sampler' interface ?

avr_fred:
2) The circuit is pretty usless for load testing an adapter.

hmm... i guess that is infact what i am trying to do - not just measuring what voltage the adapter spits out.

avr_fred:
You could use the Arduino to measure the adapter output voltage but that’s not testing - since there is no load on the adapter. The simplest way to test is to place a 2.5 ohm, 10 watt resistor across the 5v output. That will be a 2 amp load when the adapter outputs 5v. With a multimeter, measure the dc output voltage and then check the ac ripple. That’s testing it. You cannot easily test for the ac ripple with an Arduino without additional circuitry.

If this is something you need to do often, buy a usb in-line tester and load. They can be had for a few dollars on eBay.

what i actually want to do is this;

  1. i have extended one adapter cable by cutting it in the middle and inserting a 10m power cable - the device at the other end is a webcam, and there is a discernible noise on the monitor audio - am wondering whether it's because of the extra 10m, or the 'shoddy' non-soldering re-connection by twisting the wires together. (there are also a pair of cheap audio-jacks as an intermediate connection along the way)

i wanted to see what the difference is with that shoddy connection and a clean cabling.

  1. i have another power adaptor for a USB to SATA cable - i believe there is an unstable power issue because using it keeps dropping out when i try to transfer data that is more than 1 GB. (from laptop to an old internal Hard Drive)

i thought i could confirm what is happening exactly, because the multimeter shows the 12V line only puts out about 10V... :frowning:

i even searched for the "sy-002-5-12 schematic" to try and figure out if i could trouble-shoot something.. (!!) - was out of my depth obviously... (but was hoping not too deep, and thus, use it as a learning experience.)

ReverseEMF:
Here's an excellent discussion on the subject: oscilloscope - How to attach (safely?) an o-scope to various sources - Electrical Engineering Stack Exchange

thanks, i'll certainly have a look at that.

ReverseEMF:
Also, in your sketch. I'm wondering what your reasoning is for using static in your global declarations? Truly, doing so will limit the scope to the current file [or translation unit], but is this really needed? I'm asking because I don't know -- and I'm perched to learn something new :wink:

i'm afraid i can't help you there - i'm just a n00b using it - previously i was just using a simple AnalogInput sketch and plotting the values in Excel !!

so this PC scope was a "step up" from that previous setup ! :smiley:

BabyGeezer:
thanks, i'll certainly have a look at that.

Yeah, and I hope it isn't too lengthy or technical. I'm both advising caution and at the same time not wanting to ruin the fun. And, presenting that Forum Discussion was, truth be told, a Lazy Move [i.e. so I wouldn't have to type all of that ;P] .

Testing adaptors will, very likely, never present any issues that will damage your scope -- but, I tend to err on the side of overly cautious when minimal experience is a factor -- no offense.

BTW: I'm tickled by your moniker [BabyGeezer] -- I'm a Geezer, too ;D

avr_fred:
Two issues. 1) The sketch measures nothing.

When you say the "sketch measures nothing", do you mean the measurement is meaningless, or that nothing is read? I looked at the sketch, and I see an Interrupt Service routine that does a serial write of an 8-bit value supposedly acquired from the ADC, of a sample of the signal presented on A0. Thus, if this code is properly written, then it does appear to be reading something. BUT, I didn't check the details, such as if the register names are correct, or if the bit banging is correct or if the IRS call is properly coded, etc. (I don't do this kind of under-the-hood coding very often on the Arduino [do it all the time with PICs, though].

So, are you saying you see a problem with the code, or a problem with the technique?

avr_fred:
If this is something you need to do often, buy a usb in-line tester and load. They can be had for a few dollars on eBay.

I bought one of these on eBay:


After a month or so, the screen grew so dim I could barely read it!
So, I payed a little more for one of these:

and, so far, it's awesome!!! I haven't tried the PC software or the bluetooth connectivity (and probably never will!).

ReverseEMF:
Yeah, and I hope it isn't too lengthy or technical. I'm both advising caution and at the same time not wanting to ruin the fun. And, presenting that Forum Discussion was, truth be told, a Lazy Move [i.e. so I wouldn't have to type all of that ;P] .

some ppl might call it lazy, others would call it "being efficient" :slight_smile:

it was a bit on the lengthy side, and most of it was (at quick glance-thru) on probing actual mains voltage.

whereas i'm dealing with the "safer" end of the adapter - the DC end - but still a very high current for an Arduino to handle.

there was another link that was very good though - The Importance of Electrical Safety !
i certainly found that something to properly absorb ! :slight_smile:

anyway, another user on a different thread of mine, suggested this "Visual Analyser" which uses the PC sound card;
www.sillanumsoft.org/prod01.htm

certainly looks more comprehensive than the PC Scope onscreen display !

ReverseEMF:
Testing adaptors will, very likely, never present any issues that will damage your scope -- but, I tend to err on the side of overly cautious when minimal experience is a factor -- no offense.

none taken, i really am quite the n00b (Baby :wink: ) when it comes to electronic engineering - my background is mostly web pages (html to php, with some BASIC during high school computer club activities !)

so i most certainly want to play it very safe before plugging stuff in willy-nilly... that said, i've fried a HC-05 and a Nano board already ! :frowning:

ReverseEMF:
BTW: I'm tickled by your moniker [BabyGeezer] -- I'm a Geezer, too ;D

yeah, i didn't exactly grow up to radio tubes, but i did live through TV in the B/W era ! :smiley: