Cockpitbuilders.com

Main => General Discussion Board. => Topic started by: kurt-olsson on September 23, 2018, 01:12:58 PM

Title: Relay causes bad readings
Post by: kurt-olsson on September 23, 2018, 01:12:58 PM
Ok, thought i had a ground problem but i checked everything. =(

I have a 2 Channel relay that i switch on/off.

but when i switch it on i get changed values from my potentiometers! This is driving me nuts.

So basically when i set my parking brake my throttles increases from idle to full throttle position!

Do i have a bad relay? or is this some kind of interfering.

Using the Teensy other Ground the values dont jump that much, but still have this problem.


Any input is very welcome.
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 23, 2018, 02:07:42 PM
Hm... it might be some voltage drop that is giving me a hard time.

I will try to power the relay with my external 5v instead, that should do the trick.
Title: Re: Relay causes bad readings
Post by: mickc on September 23, 2018, 10:10:18 PM
How are you driving the relay?  Hopefully not directly with one of the Teensy output pins??
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 24, 2018, 02:48:11 AM
Quote from: mickc on September 23, 2018, 10:10:18 PM
How are you driving the relay?  Hopefully not directly with one of the Teensy output pins??

Yes, thats exactly what i did.
5V output from the Teensy and GND from the Teensy.

Worked axcept that i get voltage sink when activating the relay.

My plan is to drive it from my 5V PSU instead to the JDC VCC pin and also hook up Teensy 5V. That should give it stable voltages all the time. At least i think so. =)


Title: Relay causes bad readings
Post by: mickc on September 24, 2018, 03:09:12 AM
Pretty sure that will still be too much load on the Teensy pin.  It's definitely why you are having issues, and will probably burn out the teensy soon.

You should use a logic level relay board or switch it with a transistor.

Don't forget to put a diode across the coil of the relay too.

Sent from my Pixel 2 using Tapatalk

Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 24, 2018, 08:17:35 AM
Problem still the same.

I dont understand this. If my relay is fed with 5v feom a 30amp PSU. Why on earth does my teensy drop in voltage?

The relay should allrady have the power needed without my teensy dropping in voltage?

In my world only signal data sjould go from teensy to my relau.
Title: Re: Relay causes bad readings
Post by: KyleH on September 24, 2018, 09:41:21 AM
Would help if you posted a schematic of your circuit.
You need a proper transistor drive to the relay. It is possible that the previous attempts have damaged the output circuitry on the teensy due to too much current being driven through it.
Title: Re: Relay causes bad readings
Post by: 737NGer on September 24, 2018, 10:00:58 AM
Not my field of expertise, but why don't you connect the output of your teensy to a non-inverting-amplifier, then the output of the amplifier to either your mosfet or relay?
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 24, 2018, 10:19:46 AM
Yeah, a ULN2803A or Mosfet will solve this problem easily.
But i dont like it when i dont understand. :)
With external powersupply i cant see how dual channel relay can drop that much voltage. :)
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 24, 2018, 11:00:12 AM
When i am using just one relay its kind of ok but i can see a smaaaaal voltage drop. This makes my analogReaders useless.
I dont want one value if relay is active and other if not. hahaha

I am switching to an ULN2803A and a Mosfet for backlighting.
The relays that i have is overkill for the amps that i am using in my tiny lamps...
Title: Re: Relay causes bad readings
Post by: KyleH on September 24, 2018, 03:08:57 PM
Quote from: kurt-olsson on September 24, 2018, 10:19:46 AM
....
But i dont like it when i dont understand. :)
With external powersupply i cant see how dual channel relay can drop that much voltage. :)

Post you're schematic and I'll see if I can explain. I did microcontroller circuit design in my last job.
Title: Re: Relay causes bad readings
Post by: RayS on September 24, 2018, 04:26:39 PM
Are you setting the Aref on the Teensy? That input ensures that pot outputs don't change with external voltage fluctuations.

I could be wrong, but that is my understanding of how Aref works.

Here's a good article that explains it better: Basically, if you aren't setting Aref, your AnalogReads() will be useless.
https://tronixstuff.com/2013/12/12/arduino-tutorials-chapter-22-aref-pin/ (https://tronixstuff.com/2013/12/12/arduino-tutorials-chapter-22-aref-pin/)
Title: Re: Relay causes bad readings
Post by: 757Simulator on September 24, 2018, 09:17:55 PM
I'll be honest I have no idea what a Teeny is but as MickC stated:

1. You had better be placing a diode across (1N4007) the terminals of the motor

And 2. I would recommend a solid state relay such as the Kyoto KF0602D very cheap on Amazon.

Mitch
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 24, 2018, 09:49:51 PM
The solutionbis like ray point AREF. I will try to use internal low voltage first before trying external.

I remember now i had exact same problem last time with my pots but smaller jitter in values.

Without a stable voltage i can never be sure of my readings.
When thought about it ladt night, relay or other components i cant know the voltage drop so i was worried that analog read is useless combined with other components in my circuit.

ARef seems to be the solution to this.

But i will anyway use a mosfet module, the reelay is for more higher amp stuff that is overkill for my purpose.

Thanks for all help, i might have some time tonight and i will report back.

But atleast now i understand how it works and the controller have a workaround for this problem.
Title: Re: Relay causes bad readings
Post by: 737NGer on September 25, 2018, 02:38:25 AM
Just a guess though, that voltage drop would probably be caused by a reverse emf, assuming the impedance of whatever you're powering doesn't change significantly upon startup?
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 25, 2018, 09:58:14 AM
Time to take a loooong pause from my cockpit building.

Bought a Mosfet Module for the Arduino.

The module is turned on and with my voltmeter i can read 12v output, but when connecting my lamp = no light.

The mosfet is an IFR520. Some people say you cant use it but lots of tutorials with my setup.

https://www.kjell.com/se/sortiment/el-verktyg/arduino/moduler/luxorparts-mosfet-modul-for-arduino-p90631#ProductDetailedInformation (https://www.kjell.com/se/sortiment/el-verktyg/arduino/moduler/luxorparts-mosfet-modul-for-arduino-p90631#ProductDetailedInformation)
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 25, 2018, 10:49:10 AM
The IFR520 cant switch on low current.

Why does it say its compatible with Arduino when its not!
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 25, 2018, 11:22:01 AM
Fried two teensy controllers and nothing works.

No more cockpit building for a month!!!

Se you all 25th of october!
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 25, 2018, 01:16:22 PM
Back again!
Now everything works!

ULN2803A FTW!
Will never use a relay or mosfet again!
Title: Re: Relay causes bad readings
Post by: skyline223 on September 25, 2018, 05:48:01 PM
Please expand on your solution when you get a chance. I too was going to use a Arduino relay module to control the trim motor in my throttle, but now it seems that will not work?
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 25, 2018, 09:02:01 PM
Of course. Will put a report later in this thread :)
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 25, 2018, 09:33:11 PM
Report:

1. The reelay i used is prob not logic level. It demands "high" voltage to switch on/off.
Using external 5v did not help and my teensy dropped volt and my analog readings where not accurate

2. The IRF520 (Mosfet module) dont work with low level even lots of vendor say its arduino stuff. If i connected 5v direct to the signal it could light the bulb and the output worked. But for PWM and analog write from a signal pin it did not work.

3. AnalogRead problem. This is still a problem with ULN2803A, when measuring voltage across my teensy when light is on compare to off it goes from 4.97 to 4.99v. So there is a small drop here aswell. Dont know if it is noticable to readings but i need a fix for this as i will drive 2 motors aswell in this circuit.

To solve this, you can use external stuff like a regulator but i will investigate the teensy AREF that support low 1.1V for readings. This means that my load dont drop voltage that much so 1.1V will always be stable for reading in my circuit.

End of report. :)
Title: Re: Relay causes bad readings
Post by: paulnd on September 26, 2018, 05:37:18 AM
I understand your frustration.

My WIP cockpit is driven mostly by Arduinos and after first wiring them based on location (overhead, throttle, MIP etc), I've now rewired based on function, so one Arduino drives relays only, another drives LEDs, another analogue inputs etc, it also make the coding a bit easier for me but I recall that you're a professional programmer so that won't make much difference to you.

I've used opto-isolated relay modules as added protection.

There are IR"F" and IR"L" 520 modules, the "L" type appear to be logic level and a lower max threshold therefore better suited to Arduino/Teensy.

This may be helpful: http://www.gammon.com.au/motors (http://www.gammon.com.au/motors) Nick Gammon's forum has been an invaluable resource on my Arduino journey.

Paul
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 26, 2018, 06:52:21 AM
Thanks Paul, thats very interesting reading in your link!
Title: Re: Relay causes bad readings
Post by: RayS on September 26, 2018, 08:56:08 AM
I think the Teensy is best served with a true Aref voltage that's external and does nothing more than supply a reference voltage. Using a reference voltage that comes from a device that relies on a reference voltage is only asking for trouble. :-)

(Make sure you connect the grounds to the same plane.)

As to the voltage drop issue, I think that is normal behavior. Any device that drives another device is going to experience at least a small voltage drop.

Going to the 2803 was a great decision. I keep a box of them handy for any Teensy emergency that might come up.. :-)
Title: Re: Relay causes bad readings
Post by: kurt-olsson on September 26, 2018, 10:07:41 AM
Your right ray. But i want to test setting the analogreference to internal 1.1v.

My teensy will never experience a drop that big from 5v to under 1.1v even with 3 motors, lights bells connected.

Time will tell. :)