Skip to content

Commit

Permalink
update v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielguerrer authored Dec 12, 2024
1 parent 81f9888 commit 922188b
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 336 deletions.
52 changes: 29 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
## v1.0.1
* Changed maximum line length from 80 to 120. This change does not apply to the code's documentation
* Using "not in" and "is not None"
* Correcting firmware version in eeprom_firmware
* Adding callbacks
* Setting logger name to 'rava'
* Changed health startup results format
* Including hardware float generation
- Changed maximum line length from 80 to 120. This change does not apply to the code's documentation
- Using "not in" and "is not None"
- Correcting firmware version in eeprom_firmware
- Adding callbacks
- Setting logger name to 'rava'
- Changed health startup results format
- Including hardware float generation

## v1.0.2
* Checking for n > 0 in data generation
* Max n of pulse counts, bytes, ints, and floats changed to 2^16 (instead of 2^32)
* Improved the disconnection detection methodology
* Corrected the int_delta in integers generation
- Checking for n > 0 in data generation
- Max n of pulse counts, bytes, ints, and floats changed to 2^16 (instead of 2^32)
- Improved the disconnection detection methodology
- Corrected the int_delta in integers generation

## v1.1.0
* Adding numpy requirement
* Changing parameter list_output to output_type
* Including acq submodule for acquiring data from a RAVA device
* Including acq_pcs.py, acq_bytes.py, acq_ints.py, and acq_floats.py to examples/
* Including tk submodule for GUI apps defining RAVA_APP and RAVA_SUBAPP classes
* Including tk.acq used to evoke the tk acquire subapp via python3 -m rng_rava.tk.acq
* Including tk.ctrlp used to evoke the tk control panel subapp via python3 -m rng_rava.tk.ctrlp
- Adding numpy requirement
- Changing parameter list_output to output_type
- Including acq submodule for acquiring data from a RAVA device
- Including acq_pcs.py, acq_bytes.py, acq_ints.py, and acq_floats.py to examples/
- Including tk submodule for GUI apps defining RAVA_APP and RAVA_SUBAPP classes
- Including tk.acq used to evoke the tk acquire subapp via python3 -m rng_rava.tk.acq
- Including tk.ctrlp used to evoke the tk control panel subapp via python3 -m rng_rava.tk.ctrlp

## v1.2.0
* Moving configuration functionality from RAVA_APP to new class RAVA_CFG
* RAVA_APP parameter rava_class allows to choose between RAVA_RNG or RAVA_RNG_LED
* Changed RAVA_APP default show_on_startup to True; Avoid macos issue of not showing matplotlib plots
* Fixed a bug in get_rng_byte_stream_data() that was returning the same bytes for both A and B channels
* snd_rng_byte_stream_start() now empties the queue data
- Moving configuration functionality from RAVA_APP to new class RAVA_CFG
- RAVA_APP parameter rava_class allows to choose between RAVA_RNG or RAVA_RNG_LED
- Changed RAVA_APP default show_on_startup to True; Avoid macos issue of not showing matplotlib plots
- Fixed a bug in get_rng_byte_stream_data() that was returning the same bytes for both A and B channels
- snd_rng_byte_stream_start() now empties the queue data

## v1.2.1
- Correcting MANIFEST.in with the correct location of the rava logo

## v2.0.0
- Adapted for firmware v2.0.0, reflecting updates in the EEPROM, LAMP and PERIPHERALS modules
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ the serial commands used to control the RAVA device.

The RAVA_RNG class enables the request of pulse counts, random bits, random
bytes, and random numbers (integers and floats). Additionally, it establishes
the circuit's basic functionality encompassing key modules such as EEPROM, PWM,
heath tests, peripherals, and interfaces.
the circuit's basic functionality encompassing key modules such as EEPROM,
PWM BOOST, heath tests, peripherals, and interfaces.

The RAVA_RNG_AIO class offers the same functionality as RAVA_RNG but within an
asynchronous framework.

The RAVA_RNG_LED class implements the code for controlling the LED and LAMP
modules within the RAVA circuit. It allows users to adjust the color and the
intensity of the attached LED. Users can also activate the LAMP mode and
retrieve statistical information on its operation.
The RAVA_RNG_LED class implements the code for controlling the LED module
within the RAVA circuit. It allows users to adjust the color and the intensity
of an attached WS2812B LED.

For a deeper understanding of how the driver operates, please refer to the
documentation provided within the source files and the provided examples.
Expand Down Expand Up @@ -52,15 +51,15 @@ rng = rava.RAVA_RNG()
rng.connect(serial_number=rava_sns[0])
'''
The default PWM and RNG configuration parameters are stored in the EEPROM memory
and can be accessed with rng.get_eeprom_pwm() and rng.get_eeprom_rng(). If
desired, users can modify the default values using the respective snd_
functions. Additionally, it is possible to make non-permanent configuration
changes using the following commands:
The default PWM BOOST and RNG configuration parameters are stored in the EEPROM
memory and can be accessed with rng.get_eeprom_pwm_boost() and
rng.get_eeprom_rng(). If desired, users can modify the default values using the
respective snd_ functions. Additionally, it is possible to make non-permanent
configuration changes using the following commands:
'''
# Configure PWM
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['50_KHZ'], duty=20)
# Configure PWM BOOST
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['50_KHZ'], duty=20)
# Configure RNG
rng.snd_rng_setup(sampling_interval_us=10)
Expand All @@ -76,8 +75,7 @@ pc_a, pc_b = rng.get_rng_pulse_counts(n_counts=100)
bit = rng.get_rng_bits(bit_source_id=rava.D_RNG_BIT_SRC['AB_XOR'])
# Generate 100 random bytes en each channel without post-processing
bytes_a, bytes_b = rng.get_rng_bytes(n_bytes=100,
postproc_id=rava.D_RNG_POSTPROC['NONE'])
bytes_a, bytes_b = rng.get_rng_bytes(n_bytes=100, postproc_id=rava.D_RNG_POSTPROC['NONE'])
# Generate 100 8-bit integers between 0 and 99
ints8 = rng.get_rng_int8s(n_ints=100, int_delta=99)
Expand Down Expand Up @@ -160,7 +158,8 @@ python3 -m rng_rava.tk.acq
## Firmware Compatibility

Regarding the [RAVA Firmware](https://github.com/gabrielguerrer/rng_rava_firmware):
* Firmware v1.0.0 to latest is compatible with driver v1.1.0 to latest
- Driver versions v1.1.0 through v1.2.1 are compatible with Firmware v1.0.0
- Driver versions >= v2.0.0 are compatible with Firmware >= v2.0.0


## Associated projects
Expand Down
2 changes: 1 addition & 1 deletion examples/acq_bytes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
This example illustrates the generation of random bytes to binary files using
This example illustrates the generation of random bytes to binary files using
the RAVA_ACQUISITION class.
This example code is in the public domain.
Expand Down
4 changes: 2 additions & 2 deletions examples/acq_floats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
This example illustrates the generation of random floats to a binary file
This example illustrates the generation of random floats to a binary file
(numpy npy) using the RAVA_ACQUISITION class.
This example code is in the public domain.
Expand Down Expand Up @@ -35,7 +35,7 @@
rng_acq.cbkreg_progress(lambda progress: print('{:.0f}%'.format(progress)))

# Acquisition
outputs, progress, time_str = rng_acq.get_numbers(rng, N_NUMS, N_CHUNK, NUM_TYPE, NUM_MIN, NUM_MAX,
outputs, progress, time_str = rng_acq.get_numbers(rng, N_NUMS, N_CHUNK, NUM_TYPE, NUM_MIN, NUM_MAX,
OUT_FILE, OUT_PATH, OUT_BINARY, threaded=THREADED)

# Close RAVA device
Expand Down
4 changes: 2 additions & 2 deletions examples/acq_ints.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
This example illustrates the generation of random integers to a text file
This example illustrates the generation of random integers to a text file
using the RAVA_ACQUISITION class.
This example code is in the public domain.
Expand Down Expand Up @@ -36,7 +36,7 @@
rng_acq.cbkreg_progress(lambda progress: print('{:.0f}%'.format(progress)))

# Acquisition
outputs, progress, time_str = rng_acq.get_numbers(rng, N_NUMS, N_CHUNK, NUM_TYPE, NUM_MIN, NUM_MAX,
outputs, progress, time_str = rng_acq.get_numbers(rng, N_NUMS, N_CHUNK, NUM_TYPE, NUM_MIN, NUM_MAX,
OUT_FILE, OUT_PATH, OUT_BINARY, OUT_SEP, THREADED)

# Close RAVA device
Expand Down
4 changes: 2 additions & 2 deletions examples/acq_pcs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
This example illustrates the generation of pulse counts to memory array using
This example illustrates the generation of pulse counts to memory array using
the RAVA_ACQUISITION class. The generation runs in threaded mode.
This example code is in the public domain.
Expand Down Expand Up @@ -37,7 +37,7 @@ def finished(future):
# Print first 100 entries from each array
print(outputs[0][:100])
print(outputs[1][:100])

# Close RAVA device
rng.close()

Expand Down
50 changes: 26 additions & 24 deletions examples/rava_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def DEVICE():
rng.close()

rng.get_device_serial_number()
rng.get_device_temperature()
rng.get_device_free_ram()

rng.snd_device_reboot()
Expand All @@ -40,42 +39,36 @@ def EEPROM():

rng.snd_eeprom_reset_to_default()

rng.get_eeprom_device()
rng.snd_eeprom_device(temp_calib_slope=397, temp_calib_intercept=-280)
rng.snd_eeprom_device(temp_calib_slope=1, temp_calib_intercept=0)

rng.get_eeprom_firmware()

rng.get_eeprom_pwm()
rng.snd_eeprom_pwm(freq_id=rava.D_PWM_FREQ['30_KHZ'], duty=12)
rng.snd_eeprom_pwm(freq_id=rava.D_PWM_FREQ['40_KHZ'], duty=12)
rng.snd_eeprom_pwm(freq_id=rava.D_PWM_FREQ['50_KHZ'], duty=20)
rng.snd_eeprom_pwm(freq_id=rava.D_PWM_FREQ['60_KHZ'], duty=25)
rng.snd_eeprom_pwm(freq_id=rava.D_PWM_FREQ['75_KHZ'], duty=25)
rng.get_eeprom_pwm_boost()
rng.snd_eeprom_pwm_boost(freq_id=rava.D_PWM_BOOST_FREQ['30_KHZ'], duty=12)
rng.snd_eeprom_pwm_boost(freq_id=rava.D_PWM_BOOST_FREQ['40_KHZ'], duty=12)
rng.snd_eeprom_pwm_boost(freq_id=rava.D_PWM_BOOST_FREQ['50_KHZ'], duty=20)
rng.snd_eeprom_pwm_boost(freq_id=rava.D_PWM_BOOST_FREQ['60_KHZ'], duty=25)
rng.snd_eeprom_pwm_boost(freq_id=rava.D_PWM_BOOST_FREQ['75_KHZ'], duty=25)

rng.get_eeprom_rng()
rng.snd_eeprom_rng(sampling_interval_us=5)
rng.snd_eeprom_rng(sampling_interval_us=10)
rng.snd_eeprom_rng(sampling_interval_us=15)

rng.get_eeprom_led()
rng.snd_eeprom_led(led_attached=False)
rng.snd_eeprom_led(led_attached=True)
rng.snd_eeprom_led(led_n=16)

rng.get_eeprom_lamp()
rng.snd_eeprom_lamp(exp_dur_max_ms=5*60*1000, exp_z_significant=3.925, exp_mag_smooth_n_trials=20)
rng.snd_eeprom_lamp(exp_dur_max_ms=1*60*1000, exp_z_significant=3.925, exp_mag_smooth_n_trials=10)
rng.snd_eeprom_lamp(exp_movwin_n_trials=600, exp_deltahits_sigevt=94, exp_dur_max_s=300, exp_mag_smooth_n_trials=70, exp_mag_colorchg_thld=207, sound_volume=153)


def PWM():

rng.get_pwm_setup()
rng.get_pwm_boost_setup()

rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['30_KHZ'], duty=12)
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['40_KHZ'], duty=12)
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['50_KHZ'], duty=20)
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['60_KHZ'], duty=25)
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['75_KHZ'], duty=25)
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['30_KHZ'], duty=12)
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['40_KHZ'], duty=12)
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['50_KHZ'], duty=20)
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['60_KHZ'], duty=25)
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['75_KHZ'], duty=25)


def RNG():
Expand Down Expand Up @@ -108,7 +101,8 @@ def RNG():
rng.get_rng_floats(n_floats=15)

rng.get_rng_byte_stream_status()
rng.snd_rng_byte_stream_start(n_bytes=10, stream_interval_ms=200, postproc_id=rava.D_RNG_POSTPROC['NONE'])
rng.snd_rng_byte_stream_start(n_bytes=100, stream_interval_ms=100, postproc_id=rava.D_RNG_POSTPROC['NONE'])
rng.snd_rng_byte_stream_start(n_bytes=10, stream_interval_ms=0, postproc_id=rava.D_RNG_POSTPROC['NONE'])
rng.get_rng_byte_stream_data(output_type='array')
rng.snd_rng_byte_stream_stop()

Expand Down Expand Up @@ -189,6 +183,11 @@ def PERIPHERALS():
rng.snd_periph_d3_timer3_pwm(freq_prescaler=1, top=2**5-1, duty=10)
rng.snd_periph_d3_timer3_pwm(on=False)

rng.snd_periph_d3_timer3_sound(freq_hz=220, volume=255)
rng.snd_periph_d3_timer3_sound(freq_hz=440, volume=255)
rng.snd_periph_d3_timer3_sound(freq_hz=880, volume=255)
rng.snd_periph_d3_timer3_sound(freq_hz=0)

rng.snd_periph_d4_pin_change(on=True)
rng.snd_periph_d4_pin_change(on=False)

Expand All @@ -209,6 +208,7 @@ def LED():
rng.snd_led_color(color_hue=rava.D_LED_COLOR['ORANGE'], intensity=255)
rng.snd_led_color(color_hue=rava.D_LED_COLOR['YELLOW'], intensity=255)
rng.snd_led_color(color_hue=rava.D_LED_COLOR['GREEN'], intensity=255)
rng.snd_led_color(color_hue=rava.D_LED_COLOR['CYAN'], intensity=255)
rng.snd_led_color(color_hue=rava.D_LED_COLOR['BLUE'], intensity=255)
rng.snd_led_color(color_hue=rava.D_LED_COLOR['PURPLE'], intensity=255)
rng.snd_led_color(color_hue=rava.D_LED_COLOR['PINK'], intensity=255)
Expand All @@ -217,16 +217,18 @@ def LED():
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['ORANGE'], duration_ms=1000)
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['YELLOW'], duration_ms=1000)
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['GREEN'], duration_ms=1000)
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['CYAN'], duration_ms=1000)
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['BLUE'], duration_ms=1000)
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['PURPLE'], duration_ms=1000)
rng.snd_led_color_fade(color_hue_tgt=rava.D_LED_COLOR['PINK'], duration_ms=1000)

rng.snd_led_color_oscillate(n_cycles=3, duration_ms=3000)
rng.snd_led_color_oscillate(n_cycles=3, duration_ms=4000)
rng.snd_led_color_oscillate(n_cycles=10, duration_ms=10000)

rng.snd_led_intensity(intensity=0)
rng.snd_led_intensity(intensity=63)
rng.snd_led_intensity(intensity=127)
rng.snd_led_intensity(intensity=190)
rng.snd_led_intensity(intensity=191)
rng.snd_led_intensity(intensity=255)

rng.snd_led_intensity_fade(intensity_tgt=0, duration_ms=1000)
Expand Down
2 changes: 1 addition & 1 deletion examples/rng_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def main():
exit()

# Request configuration
print('\nPWM setup: {}\n'.format(await rng.get_pwm_setup()))
print('\nPWM setup: {}\n'.format(await rng.get_pwm_boost_setup()))
print('\nRNG setup: {}\n'.format(await rng.get_rng_setup()))

# Generate random data
Expand Down
8 changes: 4 additions & 4 deletions examples/rng_doubles.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def get_rng_doubles(n_doubles):
return
rnd_bytes_a, rnd_bytes_b = bytes_res

# XOR them
# XOR them
rnd_bytes = np.bitwise_xor(rnd_bytes_a, rnd_bytes_b).tobytes()

# Convert bytes to ints
# Convert bytes to ints
rnd_ints = np.frombuffer(rnd_bytes, dtype=np.uint64)

# IEEE754 bit pattern for single precision floating point value in the
# range of 1.0 - 2.0. Uses the first 52 bits and fixes the float
# exponent to 1023
Expand Down
15 changes: 7 additions & 8 deletions examples/rng_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
rng.connect(serial_number=rava_sns[0])

'''
The default PWM and RNG configuration parameters are stored in the EEPROM memory
and can be accessed with rng.get_eeprom_pwm() and rng.get_eeprom_rng(). If
desired, users can modify the default values using the respective snd_
functions. Additionally, it is possible to make non-permanent configuration
changes using the following commands:
The default PWM BOOST and RNG configuration parameters are stored in the EEPROM
memory and can be accessed with rng.get_eeprom_pwm_boost() and
rng.get_eeprom_rng(). If desired, users can modify the default values using the
respective snd_ functions. Additionally, it is possible to make non-permanent
configuration changes using the following commands:
'''

# Configure PWM
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['50_KHZ'], duty=20)
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['50_KHZ'], duty=20)

# Configure RNG
rng.snd_rng_setup(sampling_interval_us=10)
Expand All @@ -39,8 +39,7 @@
bit = rng.get_rng_bits(bit_source_id=rava.D_RNG_BIT_SRC['AB_XOR'])

# Generate 100 random bytes en each channel without post-processing
bytes_a, bytes_b = rng.get_rng_bytes(n_bytes=100,
postproc_id=rava.D_RNG_POSTPROC['NONE'])
bytes_a, bytes_b = rng.get_rng_bytes(n_bytes=100, postproc_id=rava.D_RNG_POSTPROC['NONE'])

# Generate 100 8-bit integers between 0 and 99
ints8 = rng.get_rng_int8s(n_ints=100, int_delta=99)
Expand Down
4 changes: 2 additions & 2 deletions examples/rng_pulse_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
print('No device found')
exit()

# Config PWM
rng.snd_pwm_setup(freq_id=rava.D_PWM_FREQ['50_KHZ'], duty=20)
# Config PWM BOOST
rng.snd_pwm_boost_setup(freq_id=rava.D_PWM_BOOST_FREQ['50_KHZ'], duty=20)

# Get initial sampling interval
si0 = rng.get_rng_setup()
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rng_rava"
version = "1.2.1"
version = "2.0.0"
authors = [
{ name="Gabriel Guerrer", email="[email protected]" },
]
Expand All @@ -22,4 +22,4 @@ classifiers = [
]

[project.urls]
"Homepage" = "https://github.com/gabrielguerrer/rng_rava_driver_py"
"Homepage" = "https://github.com/gabrielguerrer/rng_rava_driver_py"
4 changes: 2 additions & 2 deletions src/rng_rava/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
Distributed under the MIT license - See LICENSE for details
"""

__version__ = '1.2.1'
__version__ = '2.0.0'

from .rava_defs import *
from .rava_rng import *
from .rava_rng_aio import RAVA_RNG_AIO
from .rava_rng_led import RAVA_RNG_LED

from . import tk
from . import acq
from . import acq
Loading

0 comments on commit 922188b

Please sign in to comment.