Merge pull request 'Radme and example updates.' (#6) from develop into master
Reviewed-on: #6
This commit is contained in:
@ -12,14 +12,15 @@ The main concepts of Physical are:
|
|||||||
|
|
||||||
* Peripheral: A peripheral is a board that hosts physical I/O and usually does analog to digital conversion or
|
* Peripheral: A peripheral is a board that hosts physical I/O and usually does analog to digital conversion or
|
||||||
digital to analog conversion. A peripheral cannot function on its own, it must be connected to a node. This is more
|
digital to analog conversion. A peripheral cannot function on its own, it must be connected to a node. This is more
|
||||||
narrow than the definition of a peripheral in embedded systems generally. Peripheral support is done on the basis
|
narrow than the definition of a peripheral in embedded systems generally. Peripheral support is focused on complete
|
||||||
of complete boards, not individual components like an ADC. Abstractions for individual components should be made
|
boards, not individual components like an ADC. Although common abstractions for components specific to physical
|
||||||
separately, such as in BFPOWER drivers.
|
can be provided in this repository, general component abstractions / drivers should be made separately, such as in
|
||||||
|
BFPOWER drivers.
|
||||||
* Node: A node hosts peripherals. A node can have a commander but does not need one. A node can ignore or even override
|
* Node: A node hosts peripherals. A node can have a commander but does not need one. A node can ignore or even override
|
||||||
commands from the commander. In a complex system, nodes are intended to be kept simple, less likely to
|
commands from the commander. In a complex system, nodes are intended to be kept simple, less likely to
|
||||||
encounter an error than the commander, and in some cases should check for obvious problems in commands from the
|
encounter an error than the commander, and in some cases should check for obvious problems in commands from the
|
||||||
commander.
|
commander.
|
||||||
* Commander: A commander hosts nodes. It is possible for a device to be both a node and a commander at the same time,
|
* Commander: A commander hosts nodes. It is possible for a device to be both a node and a commander at the same time,
|
||||||
although it may not be the best idea to make such a setup. There is no concept of nesting commanders built into
|
although it may not be the best idea to make such a setup. There is no concept of nesting commanders built into
|
||||||
Physical. If some kind of abstraction for a computer that commands multiple commanders, which command nodes, is
|
Physical. If some kind of abstraction for a computer that commands multiple commanders, which command nodes, is
|
||||||
necessary, it should be made for that specific application.
|
necessary, it should be made for that specific application.
|
@ -3,20 +3,17 @@
|
|||||||
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
||||||
|
|
||||||
use core::cell::Cell;
|
use core::cell::Cell;
|
||||||
use cortex_m::prelude::{
|
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||||
_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs,
|
|
||||||
};
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||||
|
|
||||||
use ads1256::standard::input::SingleEnded;
|
use ads1256::standard::input::SingleEnded;
|
||||||
use ads1256::{
|
use ads1256::{
|
||||||
AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState,
|
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DataRate, DigitalIo,
|
||||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer,
|
DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status,
|
||||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
|
||||||
};
|
};
|
||||||
use embassy_time::{Delay, Duration, Timer};
|
use embassy_time::Delay;
|
||||||
use executor::Spawner;
|
use executor::Spawner;
|
||||||
use stm32::dma::NoDma;
|
use stm32::dma::NoDma;
|
||||||
use stm32::exti::ExtiInput;
|
use stm32::exti::ExtiInput;
|
||||||
@ -30,7 +27,7 @@ use uom::si::f32;
|
|||||||
|
|
||||||
use defmt::{debug, error, info, trace, unwrap};
|
use defmt::{debug, error, info, trace, unwrap};
|
||||||
use embassy_executor::_export::StaticCell;
|
use embassy_executor::_export::StaticCell;
|
||||||
use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3};
|
use embassy_stm32::peripherals::{PF6, PF7, SPI3};
|
||||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||||
use embassy_sync::pubsub::PubSubChannel;
|
use embassy_sync::pubsub::PubSubChannel;
|
||||||
use physical_node::transducer::{Publish, StatefulPublisher};
|
use physical_node::transducer::{Publish, StatefulPublisher};
|
||||||
|
@ -3,19 +3,16 @@
|
|||||||
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
||||||
|
|
||||||
use core::cell::Cell;
|
use core::cell::Cell;
|
||||||
use core::ops::DerefMut;
|
|
||||||
use cortex_m::prelude::{
|
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||||
_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs,
|
|
||||||
};
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||||
|
|
||||||
use ads1256::standard::input::SingleEnded;
|
use ads1256::standard::input::SingleEnded;
|
||||||
use ads1256::{
|
use ads1256::{
|
||||||
AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState,
|
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DState, DataRate, DigitalIo,
|
||||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer,
|
DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status,
|
||||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
|
||||||
};
|
};
|
||||||
use embassy_time::{Delay, Duration, Timer};
|
use embassy_time::{Delay, Duration, Timer};
|
||||||
use executor::Spawner;
|
use executor::Spawner;
|
||||||
@ -29,7 +26,7 @@ use stm32::{pac, spi};
|
|||||||
use uom::si::electric_potential::volt;
|
use uom::si::electric_potential::volt;
|
||||||
use uom::si::f32;
|
use uom::si::f32;
|
||||||
|
|
||||||
use defmt::{debug, error, info, trace, unwrap};
|
use defmt::info;
|
||||||
use embassy_executor::_export::StaticCell;
|
use embassy_executor::_export::StaticCell;
|
||||||
use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3};
|
use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3};
|
||||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||||
|
@ -2,21 +2,18 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
#![feature(type_alias_impl_trait, async_fn_in_trait)]
|
||||||
|
|
||||||
use core::cell::Cell;
|
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||||
use cortex_m::prelude::{
|
// Necessary unused import.
|
||||||
_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs,
|
|
||||||
};
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||||
|
|
||||||
use ads1256::standard::input::{Differential, SingleEnded};
|
use ads1256::standard::input::{Differential, SingleEnded};
|
||||||
use ads1256::{
|
use ads1256::{
|
||||||
AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState,
|
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DataRate, DigitalIo,
|
||||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer,
|
DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status,
|
||||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
|
||||||
};
|
};
|
||||||
use embassy_time::{Delay, Duration, Timer};
|
use embassy_time::Delay;
|
||||||
use executor::Spawner;
|
use executor::Spawner;
|
||||||
use stm32::dma::NoDma;
|
use stm32::dma::NoDma;
|
||||||
use stm32::exti::ExtiInput;
|
use stm32::exti::ExtiInput;
|
||||||
@ -26,9 +23,8 @@ use stm32::time::Hertz;
|
|||||||
use stm32::{pac, spi};
|
use stm32::{pac, spi};
|
||||||
|
|
||||||
use uom::si::electric_potential::{millivolt, volt};
|
use uom::si::electric_potential::{millivolt, volt};
|
||||||
use uom::si::f32;
|
|
||||||
|
|
||||||
use defmt::{debug, error, info, trace, unwrap};
|
use defmt::info;
|
||||||
use physical::transducer::{lm35, thermocouple_k};
|
use physical::transducer::{lm35, thermocouple_k};
|
||||||
use uom::si::thermodynamic_temperature::degree_celsius;
|
use uom::si::thermodynamic_temperature::degree_celsius;
|
||||||
|
|
||||||
@ -88,7 +84,7 @@ async fn main(spawner: Spawner) {
|
|||||||
ads_1256.self_calibrate(&mut spi).await.unwrap();
|
ads_1256.self_calibrate(&mut spi).await.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let gain = Gain::X4;
|
let gain = Gain::X2;
|
||||||
let reference = ads_1256
|
let reference = ads_1256
|
||||||
.autocal_convert(
|
.autocal_convert(
|
||||||
&mut spi,
|
&mut spi,
|
||||||
@ -101,9 +97,13 @@ async fn main(spawner: Spawner) {
|
|||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_voltage(gain);
|
.to_voltage(gain);
|
||||||
|
let reference_volts = reference.get::<volt>();
|
||||||
let reference = lm35::convert(reference).unwrap();
|
let reference = lm35::convert(reference).unwrap();
|
||||||
let reference_celsius = reference.get::<degree_celsius>();
|
let reference_celsius = reference.get::<degree_celsius>();
|
||||||
info!("Reference junction temperature: {}°C", reference_celsius);
|
info!(
|
||||||
|
"Reference junction temperature: {}°C, from voltage reading: {}V",
|
||||||
|
reference_celsius, reference_volts
|
||||||
|
);
|
||||||
|
|
||||||
let gain = Gain::X64;
|
let gain = Gain::X64;
|
||||||
let voltage = ads_1256
|
let voltage = ads_1256
|
||||||
@ -121,6 +121,6 @@ async fn main(spawner: Spawner) {
|
|||||||
let mv = voltage.get::<millivolt>();
|
let mv = voltage.get::<millivolt>();
|
||||||
let temperature = thermocouple_k::convert_direct(voltage, reference).unwrap();
|
let temperature = thermocouple_k::convert_direct(voltage, reference).unwrap();
|
||||||
let celsius = temperature.get::<degree_celsius>();
|
let celsius = temperature.get::<degree_celsius>();
|
||||||
info!("Thermocouple temperature: {}°C, millivolts: {}", celsius, mv);
|
info!("Thermocouple temperature: {}°C, from reading: {}mV", celsius, mv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user