# Understanding a PWM signal on an oscilloscope

#### ericgibbs

Joined Jan 29, 2010
8,887
hi s200,
If there are only two codes to create, ie: On and Off.
It should be a fairly easy task to recreate the waveforms shown in your post #1.
As I suggested earlier, use a Arduino and a scope to generate those two Bit patterns.
E

#### s200bym

Joined Aug 9, 2017
75
I don't know if this makes any sense to you guys but this is the excel file taken from the scope with the ON signal.

#### Attachments

• 188.4 KB Views: 12

#### spinnaker

Joined Oct 29, 2009
7,837
I wish I had finished my CSV protocol analyzer.

Again. if that is synchronous then you are going to need both clock and data pulse to make any sense of the data.

#### ericgibbs

Joined Jan 29, 2010
8,887
hi,
Plotting your csv file in Lotus, produces a copy of the ON code image that you posted earlier.
E

#### AlbertHall

Joined Jun 4, 2014
8,552
I don't know if this makes any sense to you guys but this is the excel file taken from the scope with the ON signal.
It should be possible, yes. It looks like a list of the voltage at the sampling points. The first value looks like the sampling frequency in kHz, so 2000 means 2MHz, or one sample every 0.5uS.
The voltages are near zero or near 2V. The first 2V section lasts 413 samples - 413 * 0.5us = 207us. From the 'scope picture that first pulse is likely two bit times wide which makes the bit time 207us / 2 =103us which makes about 9700Hz which is a sensible approximation to the standard 9600 baud.
Anybody care to work through the rest of the file?

#### AlbertHall

Joined Jun 4, 2014
8,552
Again. if that is synchronous then you are going to need both clock and data pulse to make any sense of the data.
Already established - there is just one data line so it can't be synchronous or SPI.

#### KeepItSimpleStupid

Joined Mar 4, 2014
3,647
The standard serial protocol has a start bit 8 bits and 1 or 2 stop bits (1.5 stop bits is possible)
The 8 bits can be 7 real data followed by with one bit of even, odd or no parity.
No parity means 8 data bits.

Way back when, the character STX (start of Text) and EOT (End of Text) were used to define "messages".

See: https://en.wikipedia.org/wiki/ASCII

From:
Standard baud rates include 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000 and 256000 bits per second

End quote.
There is an odd baud rate of 134.5 which was for the IBM Selectric terminals.

#### s200bym

Joined Aug 9, 2017
75
Could it be the 1 wire protocol?

It should be a fairly easy task to recreate the waveforms shown in your post #1.
Not for me

Sorry for my ignorance, I am learning as I go with this.

Mike.

Last edited:

#### MrChips

Joined Oct 2, 2009
19,428
CAN use a specific message frame format for receiving and transmitting the data. The two types of frame format available are:

a) Standard CAN protocol or Base frame format
b) Extended Can or Extended frame format

The following figure (Fig 2) illustrates the standard CAN frame format, which consists of seven different bit-fields.

a) A Start of Frame (SOF) field - indicates the beginning of a message frame.
b) An Arbitration field, containing a message identifier and the Remote Transmission Request (RTR) bit. The RTR bit is used to discriminate between a transmitted Data Frame and a request for data from a remote node.
c) A Control Field containing six bits in which two reserved bits (r0 and r1) and a four bit Data Length Code (DLC). The DLC indicates the number of bytes in the Data Field that follows.
d) A Data Field, containing from zero to eight bytes.
e) The CRC field, containing a fifteen-bit cyclic redundancy check-code and a recessive delimiter bit.
f) The Acknowledge field, consisting of two bits. The first one is a Slot bit which is transmitted as recessive, but is subsequently over written by dominant bits transmitted from any node that successfully receives the transmitted message. The second bit is a recessive delimiter bit.
g) The End of Frame field, consisting of seven recessive bits.

An Intermission field consisting of three recessive bits is then added after the EOF field. Then the bus is recognized to be free.

(Fig 2)

Reference:
http://www.eeherald.com/section/design-guide/esmod9.html

#### ebp

Joined Feb 8, 2018
2,332
While CAN is common in automotive applications, there is nothing at all about that signal that suggests CAN to me. CAN uses differential transmission and unless the bit pattern happened to work out "just so" so that a much larger number of bits look like 29 (plus, as I contend, a 30 that merges into the idle state), there are far too few bits at a rate far to low to be CAN.

The only thing that prevents me from being totally convinced it is just weird upside-down conventional async serial is my uncertainty that there is a STOP bit at the end of what would be the second character (20th bit from the left, counting from 1).

The apparent bit rate is inconsistent with 1-wire.

[EDIT] - Ignore following; confirmed with CVS file
It would be helpful to me to see the waveforms expanded. Set the scope to trigger on the leading edge and put the trigger on the left-most graticule position. Set the horizontal scale to 250 µs per division if possible or 200 (more likely - most scopes use 1-2-5 sequence). The latter will overflow the screen a little, but that's OK. The think I would like to see is the 20th bit, as mentioned above.

Last edited:

#### s200bym

Joined Aug 9, 2017
75
Hopefully, this helps. The only setting for the trigger are slope and falling. I have plotted the graph in excel if that helps.

I took the images from the leftmost and the rightmost.

#### Attachments

• 357.9 KB Views: 1

#### ericgibbs

Joined Jan 29, 2010
8,887
hi s200,
Look thru this list from your first csv file.
E
.... uSec hi/lo
1 207 1
2 209 0
3 103 1
4 105 0
5 103 1
6 105 0
7 103.5 1
8 104.5 0
9 103.5 1
10 104.5 0
11 311.5 1
12 208.5 0
13 207.5 1
14 105 0
15 207 1

#### ebp

Joined Feb 8, 2018
2,332
I looked at the CVS file.
- the rate about 9615 bits per second - well within acceptable tolerance for 9600 baud
- taken as 8 data bits, the stop bits are all in the correct position

#### MrChips

Joined Oct 2, 2009
19,428
I agree with @ebp.

The data is 9600 baud, 8N1.
OFF signal is $56$30 $0A. ON signal is$56 $31$0A.

#### AlbertHall

Joined Jun 4, 2014
8,552
I agree with @ebp.

The data is 9600 baud, 8N1.
OFF signal is $56$30 $0A. ON signal is$56 $31$0A.
That makes it easy to reproduce with any microcontroller such as the Arduino.

#### s200bym

Joined Aug 9, 2017
75
The data is 9600 baud, 8N1.
OFF signal is $56$30 $0A. ON signal is$56 $31$0A.
What format is that so I can try and work out how to put it into code.

Mike.

#### MrChips

Joined Oct 2, 2009
19,428
Set the UART to 9600, 8N1.
Send three bytes in succession, e.g. 0x56, 0x30, 0x0A.

Note that this is straight text, "V0" and "V1" followed by LF.
It does make sense but not very good for reliability as there is no error checking involved.

#### s200bym

Joined Aug 9, 2017
75
WOW! Thanks guys.

This is the OFF signal I am getting now with @MrChips data. Although it's inverted that can be changed. Looks pretty good to me.

Although the ON signal looks the same as the OFF

Last edited: