Running Small Program on Photon

Hello,

This is my very first post. I want to try to accomplish something with the Photon that I do not see any discussions on. I would like to write a small program that runs continuously on the Photon without transmitting any information. The program will be performing a function to do modulating of a servo. It should sample the position from feedback from a 4-20ma control board, compare it to the actual position and a setpoint from an input. Based on being high or low from the setpoint, the program should trigger one of two digital outputs with modulation as it approaches the set-point and have a dead-band as it approaches so as to not overshoot.

It should be providing feedback at intervals over the network just as usual.

The big difference here being the Photon is not required to be connected to the internet to run the program internally as the sensor and other hardware are local.

The board I am using for 4-20ma input is from control anything. So far it is too noisy and the resolution not reliable enough to use for positioning feedback. Still working that part out too. The gain is set to 2, I am collecting 16 bit data. I have also tried 12 bit.

Not sure how these two statements go together, since "providing feedback at intervals over the network" requires transmitting information. If you mean sending the information locally in your network, that has certainly been discussed on this site before. You can connect to your network without connecting to the Particle cloud. Try searching "use Photon without internet".

2 Likes

Sounds like a fun project. Do you have a specific question? You didn’t include a single “?” anywhere in your post.

The Photon can be used offline and there are various methods managing the offline state. However, you can accomplish what you want and still leave the Photon connected to a WiFi network. If you intend on running the Photon where no network is present, then you should probably consider running with SYSTEM_MODE(SEMI_AUTOMATIC) so that you control when the Photon makes network connections. If your measurements are time-critical, you may also want to consider SYSTEM_THREADING(ENABLED). Have you searched the WebIDE libraries for “servo”?.. there are several servo libraries you can use. I don’t know enough about 4-20mA positioning to give pointers on that.

1 Like

In Industrial controls we use 4-20ma signals for everything. apparently 20ma current is too little to cause a spark and blow everything up in a plant. In any event. In another aspect we want to use the feedback to position a hydraulic actuator much like you would a servo for an RC CAR or something. The difference being that you have to actuate relays that are in turn connected to a hydraulic circuit that has a pumps and such. The pressure is as high as 3000 psi but that should not matter really. The control loop provides position feedback which will be higher or lower than a second input (between 0 & 100%). Obviously 100% open or 0% open as in a closed valve.

The user inputs the position desired using either a potentiometer or a digital input from a HMI. The sensors le the photon know where it is relative to the desired position and activates the solenoids (to go one way or the other) from the current location), monitoring the progress…until it reaches the desired position and then stops firing the solenoids… holding the pressure.

I would like to have some sort of dead-band as it approaches the desired point so it does not overshoot and sit there hunting back and forth.

I am still working out the controlanything.com 4-20ma current loop sensor board. It is noisy and the output is not consistent for positioning yet. I am confident I will get there.

I any event, my real question is can the Photon do this and some other functions?

Can the Photon do data logging locally…like to a memory card somehow instead of constantly transmitting?

Can The Photon contain a sophisticated program to do data logging from 4-6 sensors over BLE and 4-20ma and compare the data to trends looking for deviations in the data and then reporting the events?

For example: reporting a power outage when it occurs and when the power comes back on. Or perhaps monitoring the time it takes to complete a “move” of a valve every time from 0% to 100% and comparing them. If the time gets longer by a threshold like say 10%, to report it.

What you are describing is a PID Controller.
A quick search revealed :Particle-PID

The photon can do everything you are asking about: reading sensors, making calculations, controlling motors/valves/etc, logging to local SDcard/FRAM/EEPROM/etc., reporting to cloud or IoT service of your choosing at regular intervals, doing all that (except cloud reporting) with or without a network connection). You may be constrained by RAM and flash size at some point (but many run very sophisticated programs despite the constraints.) You can even leverage external resources such as AI and machine learning (i.e. Azure or other services). The other constraint you may encounter is the lack of libraries which means you have to do that additional work of interfacing new components yourself. And for me, my lack of knowledge in C++ and general EE stuff is always prevalent. But even that can be solved with help from the experts on here.

1 Like

The Photon does almost everything you ask for, just not BLE natively. The Photon’s antenna does WiFi only.

If you want BLE and WiFi, choose the RedbearDuo instead. It is based on the design of the Photon, but has both WiFi and BLE antennae. In fact, Particle purchased the design, so you would be still staying within the Particle family.

1 Like

I have actually pre-ordered the Argon, Boron and Xenon which all have BLE. I ordered the Photon to "learn" about it. I would imagine the same code runs on them as well.

The documentation is severely lacking for support for advanced development. I would think the Photon staff should be on here daily engaging everyone to get their product to be used as widely as possible… Teaching, sharing, point and directing everyone to adopt it.

Boron, Xenon and Argon all have BLE coming this fall.

rftop

YOU ARE MY HERO SIR

THANK YOU VERY MUCH FOR YOUR HELP AND THE LINK!!!

They are! The prominent folks (that I know of) are @rickkas7, @ParticleD, @BDub, @mdma and others. Check out @rickkas7's githup repo, he posts amazing tutorials and other projects to further development on this platform.

2 Likes

Thanks for the feeback. I am hoping to quickly figure things out.

While we're at it, could you elaborate a bit more on that?

  • What/where is the documentation lacking?
  • What are you not finding that you were hoping you could?
  • what could be done to improve on this?
  • Did you know the docs are open source and anyone, even you, can make contributions to improve it for everyone?
4 Likes

Please take a close look again at the announcements. These devices are announced that they have BLE, but that the BLE will be initially only for setting up the devices. There are indications on the forums that there are further plans by Particle to develop the BLE functionality, but there is no commitment on when this functionality will be available and I assume development has not progressed sufficiently since Particle is not committing that it will definitely be available.

2 Likes

I misspoke. It supports Bluetooth 5 which is supposed to be backwards compatible with BLE 4.2. if the product does not support Bluetooth 5 then it is not Blueooth and should not advertise as such!

Specs
u-blox SARA R410 LTE modem
LTE CAT M1/ NB1 module with global hardware support (MVNO support for US/Mexico only)
3GPP Release 13 LTE Cat M1
Nordic Semiconductor nRF52840 SoC
ARM Cortex-M4F 32-bit processor @ 64MHz
1MB flash, 256KB RAM
IEEE 802.15.4-2006: 250 Kbps
Bluetooth 5: 2 Mbps, 1 Mbps, 500 Kbps, 125 Kbps
Supports DSP instructions, HW accelerated Floating Point Unit (FPU) calculations
ARM TrustZone CryptoCell-310 Cryptographic and security module
Up to +8 dBm TX power (down to -20 dBm in 4 dB steps)
NFC-A tag

Well, that's the rub. The Bluetooth will be very limited when it first releases. They are going to release the mesh product and use the Bluetooth to enhance end-user experience at first (joining to wi-fi, claiming, etc.). Sometime after initial release will Particle proceed to develop the API to use the Bluetooth from user firmware. So yes, they can advertise it now, but you won't get access to it for some time... hence, the rub. Since launch has been delayed a bit, I don't think you'll get a firm date on when it will be easily accessible from user firmware.

1 Like