0

Need a Simblee replacement
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Need a Simblee replacement

by oldpapa2003 on Tue Mar 05, 2019 5:56 pm

In the Central Multi, the BLUE_LED is on when connected. Can this be turned off. I know I can skip the port the LED is on, but like to find a way to remove.

I have grabbed the MAC's and exploring a good way to save in internal memory.. Simblee used a different way, it might be as simple as progmem..
need it for 4 items.
MAC for Handset
MAC for Foot Switch
Values for battery of Handset
Values for battery of Foot Switch

On the Handset and Foo tSwitch, I will not have any indicators.. LED's. These will show up on the receiver sines it has ample power. Will light LEDS for conditions on the receiver.

Once I store the MAC's, I will test what comes in after I pair with the MAC's. If MAC is not either.. Do not use.

Also, anyone know how much current the GD25Q16 uses on the feather board. Trying to get as accurate amount of current draw in the waitforevent.
Without it, I'm guessing less than 800ua.
The other board has LEDs and with me lowering the voltage, I can get 780 ua.. I don't need the LEDs, I might just pop those suckers out..

I could be gone for a bit. I have a hernia in my stomach from a past operation that removed 2/3 of the colon. Guess the small intestines are wiggling into the hernia causing
lots of pain. Seeing surgeon tomorrow.. I might look in with my tablet..

Wayne

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by adafruit_support_mike on Wed Mar 06, 2019 12:52 am

The blue LED is controlled by the firmware programmed into the nRF51822 or nRF51840. Removing the LED would be easier than rewriting and reprogramming the low-level code.

The QSPI's idle current is around 100uA. It uses about 3mA when reading, and around 10mA during an erase/write cycle.

oldpapa2003 wrote:Seeing surgeon tomorrow..

Yikes.. get healthy. We'll be here when you're back up to speed.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need a Simblee replacement

by oldpapa2003 on Fri Mar 08, 2019 3:48 pm

Well, thank you.. I'm doing much better since earlier this week. If the hernia kicks up again becomes a constant issue, I go in 4-9 for the operation. If it does very little with pain I can wait a bit. So far so good. Today is the best so far.

I have tried flashing the bootloader on 2 types of modules. The Taiyo Yuden EKSKBNZWB and the Rigado BMD-340.
I follow the instruction and was able to load onto the Taiyo and used the exact program as for the MDBT50 and works great.
But, the BMD-340, while I do not have a eval board, I soldered wires to the pads and brought the out to work with.
I can flash the bootloader ok.
I can load scripts ok.
But anything that deals with BLE the unit hangs in serial.
If I just scan for a LOW on and pin, it reports the pin went low.
The serial hangs only when bluefruit is in the script.
I need to hit the reset low 2 times to reload bootloader (basically pull out of serial monitor).
The Rigado's are available whereas the MDBT50Q are not.
The Taiyo's are avail too, but a bit costlier.
I'm debating on getting the Lairds BL654 to try.

Can you point me to what to look for.

Wayne

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by adafruit_support_mike on Sat Mar 09, 2019 1:02 am

Our BLE code for the nRF52832 and nRF52840 relies on firmware beyond just the UF2 bootloader, and I wasn't involved in the technical details at that level. I also don't know the specific board-level details that our code relies on. I do know that SOCs built around the same chip can have low-level differences that make them only kind-of compatible.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need a Simblee replacement

by oldpapa2003 on Mon Mar 11, 2019 10:15 am

Found out after reading, is module has a special DFU installed unlike the Nordic DFU in the others called RigDFU.
So I'm going to try to erase it and install the Nordic DFU. I will let you know how it goes.

NEW:
Results, the same.. I did erase the module and reloaded the nRF52 stuff.. And Adafruit stuff and same thing.
I have sent asking for help from Rigado for the reason. Also contacted Laird to see if the BL652 can work.

New2:
Found out when flash the bootloader via Arduino IDE using jLink, it flashes the device as a nRF52832 and not a nRF5240.
If I reload the bootloader as a nRF52840, will load the script but revert back to a nRF52832.

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by oldpapa2003 on Thu Mar 21, 2019 4:24 pm

So far I have no problem porting over the sketch from the Simblee to the Adafruit. In fact it is working well.
I'm now to the point I want to write the MAC addresses of the device into internal memory. This will make sure no other device will connect to the receiver unit.

I have looked into the InternalFS and have written some bogus info, but, I see that if I write again, it appends to the last address.
Is there a way to delete just 1 folder (I will have 4 folders total)
I use to store the mac addresses in non-vol memory on the simblee (took a page per mac address) and battery condition (the same as the other but took a page for 1 byte)
I see a remove in InternalFS which shows a *filepath but can not guess how to use it..
I've open the file, did file.remove(filepath); and close the file (remember the old Apple days and leaving open files).
I figure I delete the file and write a new file with new mac..

Wayne

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by adafruit_support_mike on Fri Mar 22, 2019 1:11 am

I'm afraid I don't know the InternalFS code, and don't have any useful advice to give on it. I'll check to see if anyone else knows more about it.

You might also want to check with Nordic and see if they can help. It's probably their low-level code, and they'll know it better than we do.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need a Simblee replacement

by oldpapa2003 on Fri Mar 22, 2019 8:56 am

I think Hathach might know something.. I will see if I can find him here.

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by oldpapa2003 on Fri Mar 22, 2019 10:54 am

Wow, I figured it out.. This is soooo Kool..

Its is InternalFS.rmdir(FILENAME); under the FILE_READ.. It removed the folder!!..
But using InternalFS.remove(FILENAME); is the correct way..

I was using file.remove(FILENAME);... But I looked under the example and it used InternalFS.format(true).. So I went and tried InternalFS.rmdir(FILENAME); and the
filename.txt was gone..

This shows how much I don't understand bool remove (char const *filepath); .. But Now I think I'm good to go..

Wayne

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by adafruit_support_mike on Sat Mar 23, 2019 2:00 am

Glad to hear you've figured it out!

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need a Simblee replacement

by oldpapa2003 on Thu Mar 28, 2019 11:36 am

Ok, almost done with a rewrite of the sketch..

In the old Simblee had an option to sleep called Simblee_systemOff(); This was called on the receiver side on a battery operate type to save battery.
I detected the systems voltage on all pins that had around 5 volts. When the system was on, 5 volts present and off had 0 volts.
So I did a OR'd of all pins with high resistance resistors to not to draw down that voltage. This was done if the user forgot to turn off the receiver with its ON-OFF switch.
It worked when the assigned pin went HIGH. When LOW, I needed to reset the pin and placed it back into sleep.

I See waitForEvent(); (I'm using in the Foot switch and Handset part). Guess might be answering my own question as I type.
Using the waitForEvent(); in place as Simblee_systemOff(); be a close replacement.

But my wondering mind asks, can the unit wake if it gets a signal from the radio. Maybe I just give it a try and see..

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by adafruit_support_mike on Thu Mar 28, 2019 11:55 pm

I don't think the nRF52 series can use a radio signal as a wakeup interrupt, but also don't know it as a fact. Give it a shot and see what you can find.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need a Simblee replacement

by oldpapa2003 on Tue Apr 02, 2019 12:20 pm

I could not find a way to wake the radio if it is in deep sleep.

So that is tabled for a bit.

I see adafruit has a TimeoutTimer. I have looked all over to find examples for it..

What last step in the project is to produce a single pedal operation activating 2 relays. 1 Relay is ARM and the other is Expose relay.
I have written some code (not using TimeoutTimer), and it works, well sort of works.. but it has one fault..
The conditions:
Press pedal once activates the ARM relay.
If pedal is not pressed in 9 secs drop ARM relay.
If pedal is pressed within 9 secs engage the Expose Relay and hold the ARM relay until pedal is released.
If during the 9 secs and the pedal is tap, drop the ARM relay and does not engage the Expose relay.
How long is a tap, prob a sec or so..

I have it all working until the tap. (previous pressed pedal
If I tap quick, the ARM relay which is on and drops without engaging the Expose relay.
If a bit longer, the Expose pops on along with the ARM relay and drops when the pedal is released

Code is kinda a hit or miss.. I can post it if required. Not long.. Its on the Adafruit Feather nRF52840

A good chance is that the start of this code was probably in the wrong mind path and I stuck to it.

I'm thinking that the TimeoutTimer might work better since I see restart and set, etc.
My code using millis() seems that I can't stop once its started. So some part plays with the relays (Engage I think)

The code:
Code: Select all | TOGGLE FULL SIZE
#include "bluefruit.h"

unsigned long time_now = 0;
unsigned long time_now2 = 0;
int LED = 25;
int LED2 = 26;
int SW = 23;
int SWwasLO = 0;
int noGO = 0;
int norepeat = 0;
void setup() {

  Serial.begin(115200);
  pinMode(LED, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(SW, INPUT_PULLUP);
  //digitalWrite(LED,LOW);
  //digitalWrite(LED2,LOW);
}

void loop() {

  if ((digitalRead(SW) == 0) && (SWwasLO == 1) && ((millis() - time_now > 420)))
  {
    //delay(10);
    Serial.println("At Start SW==0 SWwasLO ==1 and millis time_now");
    time_now = (millis() + 9000);
    //time_now = 0;
    //digitalWrite(LED2, HIGH);
    noGO = 1;
  }

  if (digitalRead(SW) == 0 && SWwasLO == 0)
  {
    armrlyheld();
  }
  if ((digitalRead(SW) == 1) && (SWwasLO == 1))//&& (time_now2 ==0))
  {
    timeoutrlys();
  }

  if ((digitalRead(SW) == 0) && (digitalRead(LED) == LOW) && (norepeat == 0) && (noGO == 1) && (SWwasLO == 1) && (millis() - time_now2 > 3000))
  {
    Serial.println("ARM and EXPOSE relay on");
    digitalWrite(LED2, LOW);
    //norepeat=1;
    time_now2 = 0;
  } else if ((digitalRead(SW) == 0) && (digitalRead(LED) == LOW) && (norepeat == 0) && (noGO == 1) && (SWwasLO == 1) && (millis() - time_now2 > 1020))
  {
    Serial.println(" Dropping ARM and EXPOSE");
    //digitalWrite(LED2, HIGH);
    //norepeat=1;
    time_now2 = 0;
    //SWwasLO = 0;
  }
}

void armrlyheld()
{
  Serial.println("ARM Relay Held");
  digitalWrite(LED, LOW);
  digitalWrite(LED2, HIGH);
  time_now = millis();
  time_now2 = millis();
  SWwasLO = 1;
  noGO = 1;
}

void timeoutrlys()
{
  if (millis() - time_now > 9000) {
    Serial.println("ARM and EXPOSED Relay Timed Out or Dropped");
    digitalWrite(LED, HIGH);
    digitalWrite(LED2, HIGH);
    time_now = 0;
    SWwasLO = 0;
    norepeat = 0;
    time_now2 = 0;
  }
}

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Re: Need a Simblee replacement

by adafruit_support_mike on Wed Apr 03, 2019 1:39 am

This is where I have an ethical obligation to make sure you're aware of the history of the Therac-25: a radiation therapy device that made its place in computer history as an example of software prolems leading to injury and death:

https://en.wikipedia.org/wiki/Therac-25

One key problem that was identified in later analysis is that the Therac-25 tried to do everything in software. One of the big lessons learned is that the software for safety-critical systems should operate through hardware interlocks that default to a safe condition. More generally, the default condition for any safety-critical system should be 'sitting in a safe condition' and it should only leave that state if several things happen to go right at the same time.

Another big lesson is that safety-critical systems should always operate closed-loop: the system should measure the things it controls to make sure the hardware is doing what the software expects. In this case, it would be a really, really good idea to confirm that the ARM and EXPOSE relays are in the state the software thinks they are. It's physically possible for relay contacts to weld themseves together, for instance. If the EXPOSE relay happens to stick shut while the software thinks it's open, That's Bad.

It would be good to have a way to make sure the relays are open and closed when they're supposed to be, and even better to have a circuit that cuts the microcontroller out of the control loop if there's a mismatch.

Looking at the pedal conditions you've described, I'd be inclined to rearrange them like so:

- If the system is in IDLE mode and sees the pedal released (no matter how long the press), it moves to ARM mode, stores a timeout value of 9000, and closes the ARM relay.

- While the system is in ARM mode, it subracts 1 from the timeout value every millisecond.

- If the system is in ARM mode and the timeout value reaches 0, the system opens the ARM relay and moves to IDLE mode.

- If the system is in ARM mode, the timeout value is greater than 0, and the pedal pressed, it sets a timeout value of 1000 and moves to WAIT mode.

- While the system is in WAIT mode, it subtracts 1 from the timeout value every millisecond.

- If the system is in WAIT mode, the timeout value equals 0, and the pedal is still pressed, the system moves to EXPOSE mode, sets the timeout value to N, and closes the EXPOSE relay.

- While the system is in EXPOSE mode, it decrements the timeout value by 1 every millisecond.

- If the system is in EXPOSE mode and the counter reaches 0, it opens both relays and moves to FINISH mode.

- The system remains in FINISH mode until it sees the pedal released, then goes to IDLE mode.

- If the system is in any of ARM, WAIT, or EXPOSE modes and sees the pedal released, it opens both relays immediately and goes back to IDLE mode.

That's only a rough state machine though, and I'd want to expose it to a lot of 'so what can go wrong?' testing before trusting it. You'd also want to add tests to make sure the relays are doing what they're supposed to, and hardware interlocks to enforce the basic safety conditions.

adafruit_support_mike
 
Posts: 59172
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need a Simblee replacement

by oldpapa2003 on Wed Apr 03, 2019 8:01 am

Hi Mike,

You bet we test this so much that it gets over done.
This is just a small code for me to get right before it goes into the current code.

I'm still looking for a watch dog in the nRF52840, but I have a routine that drops all relays if something goes bad.
One issue is disconnect. In the disconnect of the bluefruit , it takes some time before it drops the relays.
My routine takes takes millis's.. Test is remove battery while a pedal is pressed.. Works great.
Collision of Hand set to Foot Switch.. Routine ignores handset if footswitch is activated.

We send the test units to a place called Intertek to test.. The Simblee did pass it after I change the input for the switch activation. Lesson learned.. I was making the the a active HI when close. When RF it that unit, it triggered. So now it is a LOW active..

We have produced 2 generations of the Wireless foot switch unit. Each one goes through tests.
Check the company website www.transamericanmedical.com
The designs that I did are the Flat Panel Upgrade, Reference Monitor and the newer (Simblee Footswitch).
If you want to see the code currently, let me know..

Wayne
Im home, I will read the stuff when I get to work..

oldpapa2003
 
Posts: 41
Joined: Fri Jun 12, 2015 9:56 am

Please be positive and constructive with your questions and comments.