[SOLVED] Vary the HIGH – LOW limit from a digital signal in Arduino UNO.

Let’s say we have a 0-48V digital signal which we want to measure with our Arduino.
We use voltage divider to minimize it to 0-5V.

Is there a way then, to a have a LOW input when signal is =0 (or almost 0) and a HIGH input when signal is from approximately 0.1V-5V?

Thanks in advance!

Use one of the analog input pins and analogRead().

Russell.

A friend told me that you can change the value which LOW becomes HIGH using a potentiometer, is that right? If yes, could you give me some Explanation?

I think switch points are ~0.3 and ~0.6 x supply.
So for a 5volt Arduino 1.5volt and 3volt.

You could try a 100k resistor between input voltage and pin (not a voltage divider).
That will preserve the switch points, and limits pin current to 500uA (pin protection diodes).
Leo..

If I understand his first post he wants it to read HIGH at anything over 0.1 V. I don't think adding a 100 k series resistor will achieve that.

Russell

Yeap Russell, thanks, that's exactly what I mean!

As Russel pointed out in post #1

analogRead is likely the easiest way to go

mapped directly 0.1v = 20

so consider any value over 20 = HIGH

And that's because analog converts the signal to a number between 0-1023, right?

so there is no Problem that my signal is digital? I should just connect it to analog Input?

If yes, it seems perfect!

And that's because analog converts the signal to a number between 0-1023, right?

so there is no Problem that my signal is digital? I should just connect it to analog Input?

Right! It's just a voltage.... Both the analog & digital inputs have very high input impedance. It's just a matter of how the chip interprets whatever voltage it sees, and then it's a matter of what your software does with that information.

Hi to everybody, my first post here!

I'll use the attached solution for similar problem, with an LM393 comparator. My needs are little different, my digital input accepts from 5 to 30 Vdc , but I think can be adapted for other voltage. I tested the circuit on a breadboard and seems to work fine.

Cheers, Ale.

inputs_2.pdf (27.7 KB)

russellz:
If I understand his first post he wants it to read HIGH at anything over 0.1 V. I don't think adding a 100 k series resistor will achieve that.
Russell

There is an Atmel zero-crossing pdf on the net that uses a high value resistor on the analogue input.
A/D 0 is LOW, and >1 is HIGH. That detects 5mV.
Other A/D values can be used to separate switchpoints.
Leo..

Is there a way then, to a have a LOW input when signal is =0 (or almost 0) and a HIGH input when signal is from approximately 0.1V-5V?

From an electronics standpoint regardless of whether or not this is possible , it makes no sense because 0.1V and 0.0V are essentially the same thing using almost any semiconductors.
Explain how you arrived at this idea. If you compare TTL logic low level with logic high level there is a significant difference. Trying to implement a protocol that most likely will interpret noise as a logic HIGH is very poor engineering practice. You have virtually no noise immunity. This post is absurd unless you can give good reason to want to do such a thing (which you have yet to do).
I think your decision to do this is the result of inexperience and not realizing you should be doing your decision making at the source and not the destination.

Wawa:
There is an Atmel zero-crossing pdf on the net that uses a high value resistor on the analogue input.
A/D 0 is LOW, and >1 is HIGH. That detects 5mV.
Other A/D values can be used to separate switchpoints.
Leo..

Hmm? There's another one? The one I saw was fir wiring with mains a.c., and they did not use the adc - they just used external interrupt, since 0v and 2ish v happen at about the same time when looking at 120 vac mains.

You mean this one ?

raschemmel:
From an electronics standpoint regardless of whether or not this is possible , it makes no sense because 0.1V and 0.0V are essentially the same thing using almost any semiconductors.
Explain how you arrived at this idea. I think your decision to do this is the result of inexperience and not realizing you should be doing your decision making at the source and not the destination.

First of all, I’m indeed inexperienced, so don’t hesitate to correct me.
The problem is described in this post (Feed opto-isolator with 2 voltages and take the difference as output. - Project Guidance - Arduino Forum)

The reason that I want LOW to be very close to zero is that my system works good also at 2V and I thought that after a possible voltage divider would be even lower before inputting it to arduino.
A friend suggested an idea: to use an optocoupler with small drive voltage (for example 1V) and so when it returns in the output the digital signal, the LOW will be close to the zero I want. What do you think?

ilguargua:
I'll use the attached solution for similar problem, with an LM393 comparator.

Thank you very much ilguargua!

First of all, I never said it wasn't possible. Two different approaches have been suggested , one using analog input the other using comparators, both are viable solutions. My point is that you still haven't provided any explanation of "your system" or why it is necessary for you to implement either of the two suggested solutions. :

Let's say we have a 0-48V digital signal which we want to measure with our Arduino.
We use voltage divider to minimize it to 0-5V.

Is there a way then, to a have a LOW input when signal is =0 (or almost 0) and a HIGH input when signal is from approximately 0.1V-5V?

Tells us virtually nothing. What is "the system" ? Where does the 48 V come from ? What are you sensing ? Why do you want to do this ? You haven't told us any of these things. If a person goes to the doctor and asks him if he has a medication that will do this or that, do you think the doctor will just prescribe it ? Of course not. His job is to treat the problem, not the symptom. He will try to find out why you are asking for thsose meds. Patients who can't get the drugs they want from their doctor buy them on the street. We still don't know why you want it . What is your problem ? Incidentally, Do you understand how the comparator circuit works ? (what the thresholds are, how to calculate a voltage divider and how a comparator works ?)

I didn't say much about the system because I had already created the other post I didn't know if it's allowed.
Anyway, I have a rail CAN-BUS system which moves some vehicles. In these rails there are 6 cables:
3 current cables, two bus cables and GND. Cable Bus A sends from 0 to +24V and Bus B from -24V to 0. The Signal is digital with data rate 46.9 Kbit/s. Unfortunately I don't have more info.
Some times, after a specific point the vehicles stop communicate so it could be voltage interruption somewhere at that point. It lasts several seconds or minutes so I don't have enough time to measure manually. I want to measure from 3-4 different places to see exactly where and if there is an interruption. I want absolutely to use an optocoupler, in order to learn and to be safe bacause I am inexperienced.

I have come up with this idea..

What I hoped to accomplice with that was to use a PULLUP Digital Input and then the arduino will read HIGH when there is no voltage from no opto and LOW when there is from at least one.

What do you think? I know the circuit is a bit faulty, i hope you can correct me.

CAN BUS is anything if not reliable. Reliability is the hallmark of CAN BUS. Why else wiuld Applied Materials use DeviceNet for a 5 Million dollar wafer processing tool where a single wafer could be worth tens of thousands of dollars and any fault with all the chambers of an 8- chamber tool full of wafers near the end of the process could cost a fortune. Check your termination resistors. They are 120 ohms and there should be one at each end of the bus.
Turn off the power and measure the resistance from CAN-HI to CAN-LOW. It should be 60 ohms. The 24V is just the power. The data is sent on RS-485 Differential line trancrivers on the CAN-HI and CAN-LOW pins. It sounds like you are "CAN challenged". Maybe what you have is a CANNOT Bus.

haha I hope I CAN.
I just asked and they said we have at the end two resistors of 220 ohms parallel, one end of the resistors on one bus and the other end on the other.
I do my internship in a factory though and i can not just turn off the power, it works 24h pro day. The system works normally almost always, that problem happens approximately once every 2-5 months and gets fixed by itself.
They have replaced almost all compoments that could have a problem and next month also the rails.
I am curious to monitor what's going on there, it's a good chance to learn.

The termination resistors are usually 120 ohms, not 220 ohms . Whoever is responsible for the maintenance of that system should have purchased a CAN "SNIFFER" (A box designed to monitor and capture CAN traffic). It sounds to me like they have a "CAN of worms"...Also, the power supply should be monitored. The fact that the communication is lost does not in any way suggest there is change in the signal amplitude. CAN is differential line drive. The amplitude is never a problem because it is differential. If you don't understand that concept , research it. What you have requested in your original post will likely not help or tell you anything. You need to be capturing data 24/7 in a buffer that holds at least one hour of traffic and then wraps around. When the system crashes and the communication is lost, only the last few seconds contains the critical data that tells why it crashed so you don't need a large buffer. As soon as the communication is lost, remove the sniffer and download the data and compare it to previously saved traffic under good operating conditions when everything is working properly. You will see traffic that looks different when it crashed. You might want to inspect all the cable connections and make sure the terminators are screwed in tight. I fixed a system with a similar problem by simply replacing one terminator. Don't overlook anything. You CAN do it , but it helps to know how.

FYI, about your circuit, you should separate the outputs and monitor them separately.