SX28 or SX52 with its own battery level software
LoopyByteloose
Posts: 12,537
I have been thinking about this for a week or so and it seems feasible.· I am wonder if code already exists.
PortB has a built in comparitor that uses two or three pins [noparse][[/noparse]dependent upon internal or external output].
Could this be used to measure a low battery voltage? And then, it could issue a message [noparse][[/noparse]with the units identify]·of the condition via RS-232/rs-485 prior to shuting down.
It seems like it would have to be in an Interupt Service Routine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
PortB has a built in comparitor that uses two or three pins [noparse][[/noparse]dependent upon internal or external output].
Could this be used to measure a low battery voltage? And then, it could issue a message [noparse][[/noparse]with the units identify]·of the condition via RS-232/rs-485 prior to shuting down.
It seems like it would have to be in an Interupt Service Routine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Comments
IMO, the comparator can be used for detecting low battery situations. But some thoughts are in order:
Usually, one comparator input is connected to a reference voltage where the other is connected to the voltage to be monitored, i.e. Vdd in this case. The reference voltage, on the other hand, also has to be derived from Vdd by some means in a way that it is still stable enough when the supply voltage is reaching the battery-low warning level.
I have attached a schematic showing one solution that might work - please note, I did not test this in reality.
Let's assume for this example that the low-voltage warning level shall be 3.0 Volts:
The reference voltage is derived from the voltage drop of about 0.6V across a silicon diode. With R1 = 22kOhm, the current through R1/D1 is about 100µA @ 3V Vdd, and about 200µA @ 5V Vdd. The voltage divider built by R2/R3 must be dimensioned that the voltage at RB2 comes down to 0.6V when the supply voltage drops close to 3V. With R2 = 22KOhm and R3 = 5.6kOhm, the current through R2/R3 is about 100µA, and the voltage across R3 is about 0.6V. You might consider using a 10kOhm trim potentiometer for R3 to fine-tune the battery-low warning level.
With supply voltages above 3V, the level at RB2 (the positive comparator input) will be above 0.6V. As RB1 (the negative comparator input) is held at 0.6V, the comparator output (RB0) will be high as long as the supply voltage is above the threshold, and it will go low when the supply voltage drops below the warning level. If you want inverted logic, just swap the RB1 and RB2 pins.
There are various methods how to check the comparator status in the software. IMO, this is not time-critical at all. Therefore, it can be done within some program loop that is executed from time to time, and it must not necessarily handled by an ISR. On the other hand, port B bits, like RB0, the comparator output, can be used to trigger interrupts. So if you like, you can configure the SX in a way that an interrupt is fired when the supply voltage drops below the warning level.
When a low-level situation has been detected, you can react on that with whatever comes to your mind, like sending a message via a serial port. I'm always amused by appliances that indicate a low-voltage situation by activating a "Battery Low LED". The current required for this LED makes sure that the battery will be dead even faster .
BTW: When doing things like this, make sure that the SX brownout detection feature is turned off (DEVICE BOROFF), or set to a value below the battery-low level (e.g. DEVICE BOR22 or BOR26). Otherwise, the SX would reset before detecting the battery-low status.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
Günther
I was thinking of a voltage divider, but using the diode to create a stable reference voltage would never have occured to me. However, I easily understand how it works and why.
I have a bit of trouble with Internet jargon. I assume IMO means 'In my opinion'.
3.0 Volts would be a suitable first try as it would extend the battery use by quite a bit and still allow the SX-28 to be stable.
If there is any remaining difficulty, it will be the transmission via RS-232 or RS-485 on the lower voltage. I will have to look at the spec sheets for the MAX-232 and a RS-485 driver. If I can reliably squeeze out one message, it would be great.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
unfortunately, you can't read the SXes brownout detector. When you activate it, it simply resets the SX when the supply voltage drops below the threshold, so there is not way to send out a notification when this happens.
Kramer,
yes - you are right, "IMO" means in my opinion. Although the SX works fine at 3.3 or 3 Volts, a "regular" MAX232 will not. Therefore, you might consider using a MAX3232 instead, which works at supply voltages down to 2.5 Volts.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
This seems like an excellent combo for a remote network with the RS-485 allowing 1000m of wire and multiple modules, but it seems that I would have to get a bit more complicated unless I can locate a lower voltage RS-485 driver or settle for a higher minimum voltage to issue the message without shutting down the unit.
Brown-out can shut down the unit, but it doesn't save anything, does it? So, if there is data to be saved, you need to send it over the serial connection before the brown-out occurs.
I suppose that I could have a 'Back-up' battery. The low voltage would then switch supplies and issue a message to call for immediate battery maintence while buying time.
Anyone in rural America that has to go to a roadside mail box would be interested in an RS-485 system such as this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Right, brownout does not save anything - it simply resets the controller, i.e. when the supply voltage rises again above the brownout level, the program will be executed again like after a power-on.
The question is if RS-485 would not be an "overkill" for applications like retrieving data from a roadside mailbox. I think the volume of data to be exchanged will be relatively low per information packet thus the serial data can be sent at a low rate (say 300 Baud). Then even RS-232 or serial TTL should work along a couple of kilometers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
I located 'Low-power, slew-rate-limited' RS-485 trancievers at Maxim. I have a 20 page sheet with reference to a range of product numbers. [noparse][[/noparse]Max3430,max3460,max3030, and other].· I need to confirm availablity.
As I understand it, the brown-out is really there to support other devices that may become unreliable before the SX-Ubicom because they loose function at a higher minimum·voltage. To avoid this the 'brown-out feature' is offered to reset and/or shut down before the whole system malfunctions create problems.
I am quite amazed that you feel that RS-232 @ 300 baud might handle a couple of kilometers, but I really don't have the years of practical experience. It a simple example application. By extending the limits, the idea becomes more of system concept with many applicatons.
I am sure that real time communications, data logging with data transfer, and remote control with a low-battery shut down from a distance has a broader applications.
With the SX-28/48/52 you have the speed and flexiblity available, so it seems the RS-485 is a useful mate.
There are diverse agricultural applications that come to mind; such a multiple frost alarms for vineyards, remote feed stations, irrigation monitoring, livestock movements, remote equipment failure, and more. Radio links usually allows for only a somewhat costly pair of devices, while the RS-485 can manage many slaves on the one twisted pair.
And I have seen mailboxes in America that are 5 miles from the farm house [noparse][[/noparse]Eastern Oregon or parts of Nevada]. And of course, battery units [noparse][[/noparse]with possible solar recharge] are ultimately more flexible for easy relocation along the bus.
I guess I will have to design a board for this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Post Edited (Kramer) : 11/2/2005 12:44:18 PM GMT
RS-232 and RS-485 are serial protocol standards, and it is only logical that within the standards it is necessary to specify certain limits, like cable lengths, cable types, capacitance between the wires, etc. Each device specified to be conform with these standards must naturally fullfill the specifications. On the other hand, when you are going to build some proprietary system that will never be connected to a standard RS-232 or RS-485 device, you are free, and can use a design that works for you on one hand but which is also less expensive on the other hand.
Any communication over wires will reach limitations by some means. Let's assume a simple two-wire cable. There are several factors causing limits: The resistance of the wires, the capacity between the wires, the incuctance of the wires, the isolation between the wires, electro-magnetic losses, etc. The most critical factor is the capacity between the wires. In general, the capacity will increase with the cable length. When you feed such a cable with AC (and a serial data stream is "kinda" AC), the higher the signal frequency (the baud rate) is, the higher the losses due to the cable capacity are. When you feed 60 Hz AC into a cable, say 1000 m long, you can be pretty sure that you will have almost the same signal at the other end. When you feed in 100 kHz, or 1 MHz you will notice losses at the other hand, increasing with the signal frequency.
Things become even worse when we talk about serial data. Here, the signal usually switches between two different voltage levels, -12/+12, 0/+5, etc. where the transitions between the two levels shall have very short rise and fall times, i.e. we are talking about rectangular signals here. According to Mr. Fourier, a rectangular signal is composed of many harmonic sine waves, where a periodical square wave is composed of the basic sine wave f, plus odd harmonics, i.e. f*3, f*5, f*7, etc. with decreasing amplitudes. When you filter out, or suppress the harmonics (and this is what a cable does), the signal at the end of the cable will not only have a lower amplitude but the signal edges will be rounded, and thus can cause wrong decoding on the receiver's side.
For a remote system, the cable costs can become really an issue when you think of high-quality data cables. Therefore, it is my idea to find work-arounds when using less expensive cable types, like telephone cables. In order to minimize losses, you should use the lowest applicable data rate, and the highest possible signal level. I'm currently designing a system with one master, and (theoretically) up to 256 slaves, where each slave can control up to 16 LEDs used to indicate positions in a high rack storage area. I'm going to transfer data from the master to the slaves at 300 Baud, and I'm planning to use a 24V signal level, i.e. 0 or +24V. Depending on the size of the storage area, a total cable length of several 1000 m can be the case. I will use regular 3-wire electric cable with one wire for common ground, one for the +24V power supply for the slaves, and one for the serial data. I don't need bi-directional data communication in this case, so the three wires are all I need.
Once again, back to the brown-out feature. I agree with you, it's main purpose is to make sure that an Sx-controlled system does not become unreliable when the power supply voltage drops below a certain level. When the SX detects a brown-out, it enters its reset-state, i.e. it stops executing the program, and sets all I/O pins as inputs, i.e. to high impedance. This does not automatically mean that external components will also "behave well". Therefore, a careful design is required in any case. In a bad design, for example, a solenoid, driven by a pair of transistors may become active when the base of the first transistor floats, i.e. when it is not pulled low by an SX output pin.
In some of my applications, very "strong" power supplies are used, i.e. even when turned off, the supply voltage drops quite slowly. Without brown-out detection, it happened from time to time that the SX did not correctly do a reset after turning power on again shortly after a power off. Setting the brown-out level to 4.2 V completely cured this problem.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G