This is my first post and I am fairly new to Arduino, so please feel free to tell me I am stupid if this is a simple fix. I am an electrical engineer and working on a fairly simple senior project. The only goal of this Arduino Yun (of about 3) is to control the output of LEDs. Each LED has a 0-10V dimming wire, where, if 5 volts is applied, the LEDs output at 50%, 7.5 volts = 75% etc. I was outputting voltages through the PWM pins with this super simple code:
However, the output voltage is WAY off. I took a number of data points and recorded them in the attached excel file. I then took the data and imported it into matlab to find a best fit line and try to map the outputs that way. (ie if I want 1 V output the code maps to actually ask the Arduino for ~2.3 volts etc). However, the large gap between 1.19 volts out and 2.6 causes way too many issues. Is there something i am missing or is this a known issue with the Yun/are there any codes that correct this output somewhere on the forum or elsewhere on the internet? It would be a huge help as I have been trying to correct this myself for some time now, but it seems like everytime I come close, something else changes.
PS. Those values from the table were found using the USB power, however when powered from a power supply the outputs are equally as bad.
PSS. I am also aware that the Arduino Yun can only output up to 5V, I have already build an op-amp circuit to take care of this, but i need the output of the Arduino to be somewhat accurate from 0-5V for that to work.
Thanks in advance for any and all help. Feel free to ask questions if there is anything i did not include, as this is my first post and Im not entirely sure of everything i need to post.
Pin 3 is a pwm-capable pin on the Arduino Leonardo/Yun. That is okay.
Could you set two pins as output : pinMode( 3, OUTPUT); pinMode( 4, OUTPUT);
Set one pin to pwm 255 : analogWrite( 3, 255);
Set another pin to HIGH : digitalWrite( 4, HIGH);
Measure pin : 5V, 3, 4
Are they somwhere near 5.00V ?
The Yun wifi/linux modules requires maybe 250mA. If you power it with USB and that is not very strong (weak cable, laptop, unpowered hub), the voltage is not 5V but 4.5V.
You might need an external power supply of 7.5V to the DC barrel jack. The Arduino Yun is does not have a good power circuit. If you use a 9V power supply, a voltage controller might get too hot.
An OpAmp to create 10V is okay.
There is another option : use a DC-DC converter to make 10V out of the 5V. Amplifiy the PWM signal to 10V and filter that. After filtering it will be an analog value between 0 and 10V.
Perhaps even a digital potmeter is possible.
Thank you for your quick response. You are correct in assuming they are not 5.0, but closer to 4.43. Could you give a link for the 7.5V external power adapter? Correct me if I'm wrong, but I'm assuming that applying 7.5 volts to the Vin pin would fry the board (After seeing it must be regulated 5.0 +- 0.25V). Do you think that this increase in power supply voltage will correct the output values, or will i still need some sort of coding/equations to make this work. I guess the bottom line is, "is this a normal problem with Yun, or just mine?"
I will look into the DC-DC converter, that might be easier in the scope of the project, however, for now, we have the op-amp circuit built and it is actually being used in other sections of the project.
I'm the one that has to apologize ! The Yun doesn't have a DC barrel jack input ! Sorry :-[
The VIN must be 5V. Perhaps you have a regulated power supply of 5V 1A. Some powered USB hubs come with such a power supply.
You can use a DC-DC converter with output of 5V and connect that to VIN, if you want to lower a voltage.
You can use a DC-DC converter to make 10V from 5V, if you want a higher voltage.
The 4.43V is very low. The Yun has an onboard DC-DC converter to make 3.3V for the wifi/linux module, perhaps that circuit is starting to fail.
When the Arduino Yun is running at 4.43V, the output of a pin can be maximum 4.43V.
The 0-10V is some kind of industry standard (I would not call it a 'standard'), but the Arduino has trouble with the higher voltage.
Its perfectly fine! I thought i was beginning to lose my mind when you mentioned a DC barrel jack. I do not believe the power circuit is beginning to fail though. We have three boards in our project and all three have the same output, and are all brand new. I have a new question for you. What will happen to the board if I leave Vin = 5.5V? When you mentioned the wifi/linux module drawing so much power, I decided to experiment on an extra board. With the Vin = 5.5V, i get perfect output from 2.8-5V, and was able to use matlab to map equations using a line of best fit to get nearly perfect output from 0-1.2V.
I still do not have access to voltages between 1.2 and 2.8V, but will probably use another op-amp circuit (specifically an inverting summer, and then another inverter to have the final output be positive) to access those values. I can just use multiple output pins to sum together to what i need. (ie if the user wants 2.2V, have pin 3 = 1.2V and pin 5 = 1.0V). That shouldnt be hard to put together at all. I could even use that circuit to sum together my total output and effectively double it to get the 10V i need. Here is the code i used to correct the lower end of the spectrum:
You can see the huge improvement in percent error on the bottom table in the PDF after those poly fit equations were added from matlab to the code.
I guess the bottom line is what will happen to the board if i leave Vin = 5.5V? Since it was an extra board, i let it run for a few hours, and the wifi module didnt even heat up and everything appears to be running just fine.
The wifi/linux module has a onboard dc-dc converter that makes 3.3V out of the 5V. When the 5V is higher, the wifi/linux will always get the 3.3V.
The ATmega32U4 chip (the arduino part of the board) has a maximum voltage of 5.5V for normal operation and will break at 6.0V according to the datasheet. But please don't do go near the limit, use a voltage of 5.0V.
I did not have the pinMode(3, OUTPUT), in my simple testing code.....silly me. But i do have it now in my actual code that will be uploaded to the device. How much, if at all will that change my output?
The code is attached, becasue putting it in the code braces makes my post exceeds the 9000 character limit.
With the maxium operating voltage at 5.5V, it is very tempting to use the Vin = 5.25, or something close to that if i can get it to work with perfect percent erorr. I will continue to work on getting the output to work without overloading the input voltage, but this code will be the only thing on the board, and the three output pins will be the only duty of this particular board in our system. So i do not believe we will be overworking the board at all. On top of that, the machine we are building for our senior project costs in the ballpark of $5,000-$6,000, and a few of the parts on the inside will need replaced from time to time. Putting a notice in the user manual that the Arduino may overheat and need replaced (A $60 device) is not going to be a huge deal to my college if it means getting accurate control systems in the final project.
I really do appreaciate all the help though from everyone. Its nice to see that new members questions are not simply glanced over as newbie questions that can be found somewhere on the internet, and that I'm treated as a member, not a newbie, even though I most certainly am.
That is not a sketch http://snippets-r-us.com/ 8)
By inserting this link, I think I just treated you as a newbie
I'm okay with 5.25V.
The ATmega chip can measure its own VCC by using its internal reference. When the VCC is used as reference it might be handy to know the voltage. You could for example measure if it is 5.03 or 5.26 and even show that on a webpage that is on a micro-SD card.
Search for "arduino readvcc" or "secret volt meter", although those example are for an Arduino Uno. I think I have tested it on a ATmega32U4 (the microcontroller in the Leonardo and the Yun).
Haha its perfectly fine, as I said before, I am. Its generally the same code, but much longer, with many more equations from matlab. Bottom line, it currently works, except for that range between 1.2 and 2.8 that for some reason the Arduino doesnt have access to output. I can correct that with a voltage summer, and should be good to go from there. Thank you very much for your help!
There is another option : use a DC-DC converter to make 10V out of the 5V. Amplifiy the PWM signal to 10V and filter that. After filtering it will be an analog value between 0 and 10V.
This looks very unconvincing to me. I doubt that if you apply a varying input voltage to a 5V to 10V DC-DC converter, you are going to get an output that varies linearly with the input.
No, not like that. I mean a PWM signal that is amplified from 0_5V to 0_10V.
A DC-DC converter can be used to make 10V (out of 5V). Use that 10V for the output circuit.
The circuit can be make with a few components or use a mosfet-gate-driver chip, that has logic level in, and full swing 10V output. Filter that, and you get 0..10V.
You are right again good friend. It is the power circuit. I assumed that there was no way that could be the reason seeing as this is a brand new board (and the second board to have this output issue of 4). We had a new board come about a week ago that we had not yet opened. I opened it up and it works near flawless. Therefore all of my work charting and fixing the output was useless . I'm not sure what to do with the board with the broken output, because everything else works just fine. We may just use it for the digital output pins to control low voltage switches as the voltage value does not matter, just that it is actually applying a voltage, which it can do. Thank you for all of your help and sorry I "technically" wasted your time seeing that it was a broken board and not actually something we could fix. Although i got pretty close haha.
If it is broken beyond repair, all you need is a big hammer...
Someone else might shuffle a few boards while you are away. It is also possible that more is damaged than you know. Sometimes they get damaged, it happens. Get rid of it and forget about it.
I don't damage Arduino boards so often anymore, although I did damage two barebone ATmega projects last year. I had to cut the ATmega chip out of the circuit and solder a new one in.
The power circuit is most likely broken beyond repair, at least for a newbie like myself.
It is only "broken" though for a specified output. If we are just using it for things that need outputs that are simply set to HIGH, then they should work just fine. It does dissappoint me though that 2 of the 4 Yuns that we bought were defective. I'm hoping im just super unlucky (which wouldnt surprise me) and that the Yuns arent 50% defective. I was told they were on the lower end of the Arduino spectrum, but I'm hoping not that low.
As far as I know, there are no fake or clone Yun boards. The official boards should work, or ask for replacement.
It is however very unlikely that a new official Yun board is broken. I don't know what could have happened.
Hi, just to recap.
Have you solved the non-linearity?
Was it a faulty Yun or are you manipulating the output of the Yun with software?
When you measure the output of the PWM with the DMM, what is the DMM and in
what range?
Do you have the output connected to any other circuit at the time?
Have you got gnds connected together?
Tom.......
Sorry but sooo much to read through then you say 2 out of 4 boards faulty...