Sine voltage waveform is square with spikes!

Hi All.

Can you help me, please? I wish to inject an analogue sine-wave voltage into an HRV trace as a time stamp.
I suspect the problem described below lies with capacitance/electronic issues - and not with my programming!

Figure 1, above, is a digital representation of a sine-wave signal from an ArduinoUno. The plot is captured by the Arduino plotter. The straight lines are simply LOW outputs, nulls.

Figure 2, above, is the digital plot captured by a DataQ device. The data comes from the digital output pin, DpinOut=13.

Figure 3, above, is a plot also captured by a DataQ device. This time the data comes from the analogue output pin, ApinOut= 9.

This test waveform is meant to have a cycle time of 40 milli-seconds - with big gaps between each cycle.

The three problems are:

    1. The signal in Figure 2 has a square profile – it should have a sine-wave pattern as shown in Figure 1.
    1. There are big spikes in the digital profile shown in Figure 2. The spikes are in both the positive and negative directions.
    1. There are even bigger spikes in the digital profile shown in Figure 3.

Can you help me solve the three problems above?

Apologies in advance: I am just quietly hacking here without knowing really what I’m doing.

Look forward to your ideas/pointers! Thanks

EGB

Moderator edit: image links corrected

How can I delete this post?
It does not show the Google Drive links!
EGB

You can't get analog out of an Uno. analogWrite() is PWM which can control the speed of a motor or change the apparent brightness of an LED. Or, it can be filtered to DC (analog).

Most Arduino's don't have an analogue output.

analogWrite() outputs a square wave with a variable duty cycle (PWM),
that can be transformed into a sine wave with an RC filter.

Please post pictures here, not on Google.
Leo..

EGB:
Figure 1, above, is a digital representation of a sine-wave signal from an ArduinoUno. The plot is captured by the Arduino plotter. The straight lines are simply LOW outputs, nulls.

How did you obtain that 'digital representation' of a sinewave from an Uno? An Uno hasn't got that particular functionality, unless external filtering of an Uno-generated signal is done.

The picture is more like a bell-curve or Lorentzian type of curve, rather than sinewave. But, anyway, maybe you can use an Arduino Due to produce sinewaves with its D-to-A capability ..... even though it has some voltage range limitations.

EGB:
How can I delete this post?
It does not show the Google Drive links!

Well, firstly, deleting posts is rude - asking for help and then saying you do not want help after all while people are working on an answer for you.

You cannot delete the "original" post but can delete your own answers if you want to play silly buggers (and risk being removed wholesale). You certainly may modify posts in order to add information or to clarify information, but need to explain this in order not to cause confusion.

As to your Google Drive "links", well, to post a link as an image, you must post a link to an image. If instead, as you have, you post a link to a Web page, well, a web page is simply not an image you see, so we will not see. :astonished: You really need to understand how the Web works. Google Drive is not a good place to share information. :roll_eyes:

As it is said, when all else fails, read (and follow) the instructions. :grinning:

Paul__B:
... deleting posts is rude ... You cannot delete the "original" post but ... Google Drive is not a good place to share information ... read (and follow) the instructions. :grinning:

Thank you, Paul__B, I learnt some valuable things from you. Appreciated! About posting a link to an image: that's what I stuggled with last night. I'll read those instructions again.

A moral is "Don't submit your first request for help to a forum late at night, especially when you are tired".

EGB.

DVDdoug:
You can't get analog out of an Uno. analogWrite() is PWM which can control the speed of a motor or change the apparent brightness of an LED. Or, it can be filtered to DC (analog).

DVDdoug: The idea that an Arduino outputs only square waves is likely part of my problem!

Wawa:
Most Arduino's don't have an analogue output. ... analogWrite() outputs a square wave with a variable duty cycle (PWM),
that can be transformed into a sine wave with an RC filter. Leo..

Wawa and DVDdoug: I wish to avoid the RC filter stuff, to minimise involvement with building circuits, so I need to get away from the limitations of the Uno. Sounds good!

Southpark:
... maybe you can use an Arduino Due to produce sinewaves with its D-to-A capability ..... even though it has some voltage range limitations.

Southpark: Thank you. For me, the bottom line of your advice is that "maybe you can use an Arduino Due to produce sinewaves with its D-to-A capability ... even though it has some voltage range limitations."

[Solved] I have to return to the drawing board. The focus will be on an Arduino Due.

Thanks a million!
EGB

Southpark:

How did you obtain that 'digital representation' of a sinewave from an Uno? An Uno hasn't got that particular functionality, unless external filtering of an Uno-generated signal is done.

The picture is more like a bell-curve or Lorentzian type of curve, rather than sinewave. But, anyway, maybe you can use an Arduino Due to produce sinewaves with its D-to-A capability ..... even though it has some voltage range limitations.

I admit to having never used anything with D/A converters. But, won't the output be a stepped representation of a true sine wave and require a low pass filter to clean up the steps?

Paul

Paul_KD7HB:
I admit to having never used anything with D/A converters. But, won't the output be a stepped representation of a true sine wave and require a low pass filter to clean up the steps?

Paul

I certainly agree on this Paul. A low-pass filter will remove the high frequency components associated with the stair-case output waveform.

And....to the OP.... the Arduino Due works with 3.3 V input/output pins ----- just mentioning this (just in case).