Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
morgendagen committed Jan 8, 2024
0 parents commit 1c27f37
Show file tree
Hide file tree
Showing 21 changed files with 4,113 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BreakBeforeBraces: Linux
ColumnLimit: 0
IndentWidth: 4
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.venv/
21 changes: 21 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Peder Toftegaard Olsen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
190 changes: 190 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# Riden Multi-Purpose WiFi Dongle Firmware

This is an alternative firmware for the Riden WiFi module that
provides Modbus TCP and SCPI support as well as a web interface.

The firmware has been tested with various tools and libraries:

- Riden Hardware
- RD6006
- Riden Firmware
- Riden v1.28
- Riden v1.41
- Unisoft v1.41.1k
- Modbus TCP
- [Python pyModbusTCP library](https://pypi.org/project/pyModbusTCP/)
- [Python pymodbus library](https://pypi.org/project/pymodbus/)
- A modified version of [ridengui](https://github.com/ShayBox/RidenGUI)
with Modbus TCP support hacked in
- SCPI
- [lxi-tools](https://github.com/lxi-tools/lxi-tools)
- [EEZ Studio](https://www.envox.eu/studio/studio-introduction/)


## Features

- Modbus RTU client communicating with Riden power supply firmware.
- Modbus TCP bridge.
- SCPI control.
- Web interface to configure the dongle.
- Web Portal to set up WiFi as well as do firmware updates.
- Automatically set power supply clock based on NTP.
- mDNS advertising.


## Warning

- When flashing the Riden WiFi module you _will_ erase the existing firmware.
- The firmware provided in this repository comes with no warranty.


## Hardware Preparations

This one had me stuck for some time. To quote from
https://community.home-assistant.io/t/riden-rd6006-dc-power-supply-ha-support-wifi/163849:

> I had to do small modification to the wifi board - I snipped one pin
> from the pinheader (EN-Enable) so it does not make contact with the
> power supply and soldered 1k resistor between EN and 3.3V. It is done
> because the PS enables wifi module only in “wifi mode” but I need it
> to run in “TTL mode” as well.
In order to flash an existing Riden WiFi module, solder on
three additional wires: GPIO0, EN, and 3.3V. In order to ease
development you may want to terminate the wires in a Dupont header connector
allowing you to more easily use an ESP01 USB Serial Adapter or similar.


## Compiling the Firmware

You will need [PlatformIO](https://platformio.org/) to compile the
firmware.

No configuration is necessary; simply execute `pio run` and wait.
The firmware is located at `.pio/build/esp01_1m/firmware.bin`.


## Flashing the Firmware

Provided you have prepared the hardware as described, connect
it to your computer as you would when flashing any other ESP12F module.

Execute

pio run -t upload --upload-port <ESP12F serial port>

and wait for the firmware to be flashed.

Before re-inserting the module into your power supply,
it may be a good idea to make the necessary configuration
changes. You need to select `TTL` as the communications mode,
and 9600 as the speed.

Re-insert the module and power up the power supply.

The module will begin to flash, first slowly and then
faster. If it starts flashing really fast (5 flashes
per second), you propably misconfigured the power supply.
Double-check, and if you are still having issues, add
an issue to the Github repository.

If all is well, the module has created a new access
point, named `RDxxxx-ssssssss` (`xxxx` is the model
and `ssssssss` is the serial number).

Connect to this access point, and you will be greeted
by a web page for configuring the WiFi network that the
module should connect to.

Follow the instructions, and save the configuration.

If all goes well, the blue LED will start to flash slowly
after a short while. You should now be able to connect
to it at http://RDxxxx-ssssssss.local.


## Using lxi-tools to Verify Installation

Execute the command

lxi discover -m

to get a list of discovered SCPI devices on the network.
This firmware sneakily advertised `lxi` support in order
for lxi-tools to recognise it.

Execute the command

lxi scpi -a RDxxxx-ssssssss.local -r "*IDN?"

to retrieve the SCPI identification string containing
power supply model, and firmware version.

Execute the command

lxi scpi -a RDxxxx-ssssssss.local -r "VOLT?"

to retrieve the currently set voltage.

Invoke

lxi scpi -a RDxxxx-ssssssss.local -r "VOLT 3.3"

to set the voltage to 3.3V

A description of the available commands are available
in [SCPI_COMMANDS.md](SCPI_COMMANDS.md).


## OTA firmware update

In order to update the firmware, you may prefer
to use OTA update instead of having to remove
the module.

Reboot in to config portal using the web interface.
Connect to the module's access point (see above),
hit Update and select your new `firmware.bin`.


## Limitations

The Riden power supply firmware have some quirks, described
below. The firmware provided here err towards caution, and
does not implement functionality that is known to be
unreliable.

### Currently Active OVP and OCP Values

There is no way to reliably retrieve these values. If they are set
by selecting a preset, M0 does not reflect the new values. If they
are set via the front panel, M0 does reflect the new values.

Therefore I have decided NOT to support `*SAV`. `*RCL` is implemented.

### Preset Register

The Preset register (19) only reflects the active preset if
changed via the modbus interface. It is not updated if a preset
is selected using the front panel. Therefore it is currently not
possible to retrieve the selected preset. `*RCL` is available for
_recalling_ a preset.

### Language Selection

Only 0 and 1 are recognized when setting the Language register. Reading
the register matches the language set from the front panel.

### Keypad

It is not possible to control keypad lock.


## Credits

- https://github.com/emelianov/modbus-esp8266
- https://github.com/sfeister/scpi-parser-arduino
- https://github.com/j123b567/scpi-parser
- https://github.com/ShayBox/Riden
- https://github.com/tzapu/WiFiManager
- https://github.com/nayarsystems/posix_tz_db
154 changes: 154 additions & 0 deletions SCPI_COMMANDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# SCPI Commands

This file lists the SCPI commands implemented in the firmware.

Mandated and required SCPI commands are recognized as well,
but may not perform as expected.


## *RCL {preset}

Restore a saved preset. **preset** must be between 1 and 9.


## SYSTem:ERRor[:NEXT]?

Returns and at the same time deletes the oldest entry in the error queue.


## SYSTem:ERRor:COUNt?

Returns the number of entries in the error queue.


## SYSTem:VERSion?

Returns the version of SCPI (Standard Commands for Programmable Instruments)
that the instrument complies with.


## DISPlay:BRIGhtness {level}

Set the display's brightness level. **level** must be between 0 and 5.


## DISPlay:BRIGhtness?

Returns the display's brightness level.


## DISPlay:LANGuage {language}

Set the front panel language. **language** is either
a number between 0 and 4 or **ENGLISH**, **CHINESE**,
**GERMAN**, **FRENCH** or **RUSSIAN**.


## DISPlay:LANGuage?

Returns the front panel language.


## SYSTem:DATE {year} {month} {day}

Set the power supply date.


## SYSTem:DATE?

Returns the power supply date.


## SYSTem:TIME {hour} {minute} {second}

Set the power supply time of day.


## SYSTem:TIME?

Returns the power supply time of day.


## OUTPut[:STATe] {0 | 1 | on | off}

The output state.


## OUTPut[:STATe]?

Returns the output state.


## OUTPut:MODE?

The output mode, either CV or CC.


## [SOURce]:VOLTage[:LEVel][:IMMediate][:AMPLitude] {voltage}

Set the output voltage.


## [SOURce]:VOLTage[:LEVel][:IMMediate][:AMPLitude]?

Returns the output voltage.


## [SOURce]:VOLTage:PROTection:TRIPped?

Returns whether the OVP is tripped.


## [SOURce]:CURRent[:LEVel][:IMMediate][:AMPLitude] {current}

Set the output current.


## [SOURce]:CURRent[:LEVel][:IMMediate][:AMPLitude]?

Returns the output current.


## [SOURce]:CURRent:PROTection:TRIPped?

Returns whether the OCP is tripped.


## MEASure[:SCALar]:VOLTage[:DC]?

Returns the measured output voltage.


## MEASure[:SCALar]:CURRent[:DC]?

Returns the measured output current.


## MEASure[:SCALar]:POWer[:DC]?

Returns the measured output power.


## MEASure[:SCALar]:TEMPerature[:THERmistor][:DC]? {SYSTEM | PROBE}

Returns the system or probe temperature.


## [SOURce]:VOLTage:LIMit {voltage}

Set the Over-Voltage Protection value.


## [SOURce]:CURRent:LIMit {current}

Set the Over-Current Protection value.


## SYSTem:BEEPer:STATe {0 | 1 | on | off}

Control the buzzer.


## SYSTem:BEEPer:STATe?

Returns the buzzer state.
Loading

0 comments on commit 1c27f37

Please sign in to comment.