# Make Fake\_Servo a firmware setting? Please :)

**URL:** <https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891>\
**Category:** Software\
**Created:** [August 17, 2019, 8:18pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891 "2019-08-17T20:18:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 8:18pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/1 "2019-08-17T20:18:21Z")

</div>

Would anyone be against making FAKE\_SERVO a firmware setting rather than a define directive? It would greatly assist in testing and troubleshooting firmware and eliminate the time to recompile and upload firmware.

To make sure someone doesn’t accidentally put it into fake servo mode, we can make it an integer and someone has to type in the correct number to put it into that mode. Some special number that answers the ultimate question of life, the universe, and everything…

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [August 17, 2019, 8:36pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/2 "2019-08-17T20:36:07Z")

</div>

I think it should be easily set, and I don’t see a good reason to make it  
cryptic, instead make it so that when if fake servo mode it regularly outputs  
a message (say ‘motors disabled, in fake mode’ or something like that)

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2019, 8:45pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/3 "2019-08-17T20:45:27Z")

</div>

One thing to be aware of is that by going into FAKE\_SERVO mode, one loses the real chain position. Just means recalibrating the chains, but needs to be remembered. I use a second Mega and drive board, but then I’ve got a number of those on hand 😄

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 8:47pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/4 "2019-08-17T20:47:51Z")

</div>

Most of my development isnt with an actual sled attached and sometimes I’ve got a real firmware installed. Just would be easier to flip a switch than to recompile/upload.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [August 17, 2019, 8:59pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/5 "2019-08-17T20:59:54Z")

</div>

make it so that when you turn on fake mode, it reports the current chain lengths  
so they can be changed back later (at least for the first cut, long term why not  
save them when you go into fake mode and restore them when you go out of fake  
make?)

David Lang

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2019, 9:42pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/6 "2019-08-17T21:42:24Z")

</div>

> [@madgrizzle](#):
>
> making FAKE\_SERVO a firmware setting rather than a define directive?

Are you thinking something in the Settings/Advanced list, or a Bxx directive?

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 9:49pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/7 "2019-08-17T21:49:57Z")

</div>

It could be either. A b command would be pretty easy to implement (no changes to ground control if you require it to be macro). We could potentially save the current steps to eeprom before entering fake servo and restore it upon exiting fake servo.

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 9:56pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/8 "2019-08-17T21:56:07Z")

</div>

But then again… do we need to save steps while in fake servo mode?

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2019, 10:16pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/9 "2019-08-17T22:16:58Z")

</div>

Better make as few changes as possible, just save/restore when changing modes. Instead of a Bxx command, maybe a $RST= something in systemExecuteCmdstring()?

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 10:27pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/10 "2019-08-17T22:27:36Z")

</div>

Would be easy to save current steps upon entering and restore upon exit and block saving when in fake servo mode… I think it makes sense to save the state (whether fake servo or not) and easiest place to do that is as a firmware setting. If that’s the case, it would be easy and simple to add it to advanced settings of ground control and webcontrol.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2019, 10:43pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/11 "2019-08-17T22:43:41Z")

</div>

> [@madgrizzle](#):
>
> block saving when in fake servo mode…

That worries me, not sure what the hidden consequences might be.  
I’d say use a separate location for saving the position when entering FS, leave the normal position handling alone, still operating. When leaving FS, restore the position from where FS stored it. FS is supposed to be as much like real as possible.  
Note that adding position saving adds a testing burden to the change. If there is no expectation that the chains should maintain calibration, rigorous dynamic testing wouldn’t be needed.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2019, 11:07pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/12 "2019-08-17T23:07:41Z")

</div>

Just ran a cut filke in FAKE\_SERVO mode with motors attached. The motors move, because of the way FS “Adds up to 10% error just to simulate servo noise”. Even with the randomness removed, the motors are clearly not completely still.  
I worry about reducing the usefulness of FS mode by trying to avoid chain recalibration. How about we just assume that the chains will need recal if FS mode has been entered/left? Maybe post an alert on exit to remind that they need recal?

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 11:18pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/13 "2019-08-17T23:18:50Z")

</div>

If the motors move while in fake servo mode, then you should never run it in fake servo mode with a sled attached. Considering the users of fake servo, I don’t think a warning is needed… I think that would be expected if you ran the motors without a sled attached Let’s just make it a RST or B command to enter and leave the mode and save the setting in eeprom under settings… it doesn’t have to have a firmware key assigned, just put the variable at the end. I prefer the B command because it’s slightly easier to implement.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2019, 11:30pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/14 "2019-08-17T23:30:09Z")

</div>

> [@madgrizzle](#):
>
> save the setting in eeprom under settings

If we do that, we have to change the SETTINGSVERSION, and that means EEPROM settings would get set to defaults when the firmware is first used for all users whether they care about this or not. Can we avoid that by not saving the state of FAKE\_SERVO under the official settings? Maybe poke a byte out at the end of EEPROM that only FS knows/cares about; if that byte gets trashed the board doesn’t go into FS mode.

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 11:37pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/15 "2019-08-17T23:37:04Z")

</div>

Is there a free byte in between the structures? Is the eeprom perfectly packed or were the addresses picked provide some space where we can use one of the bytes. Not at a computer to try to do a sizeof

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2019, 11:40pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/16 "2019-08-17T23:40:00Z")

</div>

Settingsversion starts at 300 and is two bytes of data… steps start at 310.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 18, 2019, 1:33am UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/17 "2019-08-18T01:33:17Z")

</div>

[Here’s](https://github.com/blurfl/Firmware/tree/add-command-for-FAKE_SERVO-mode) a whack at it.

```auto
 - $RST=F toggles the state
 - the state is saved in EEPROM[4095], if not zero, FAKE_SERVO mode
 - the state is shown in a line printed at startup and when changed

```

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 18, 2019, 4:57pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/18 "2019-08-18T16:57:50Z")

</div>

Does EEPROM[FAKE\_SERVO] cause an EEPROM read to occur or does it use a cached value? I had some issues on the teensy where EEPROM activity would cause me problems with encoders.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 18, 2019, 5:33pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/19 "2019-08-18T17:33:57Z")

</div>

I’m afraid it’s a read(). It only happens at first startup and when the command is sent, though.

FWIW, I’ve got a version that uses B99 instead of the $RST=F if that would be preferable. Should B99 toggle the state, or should it require an additional parameter - ‘B99 1’ for on, ‘B99 ~anything-else~’ for off?

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 18, 2019, 5:51pm UTC](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891/20 "2019-08-18T17:51:27Z")

</div>

> [@blurfl](#):
>
> I’m afraid it’s a read(). It only happens at first startup and when the command is sent, though.

It’s called continuously during a move isn’t it?

As for b command… I prefer a 1 to enable and anything else to disable.

[Next page](https://forums.maslowcnc.com/t/make-fake-servo-a-firmware-setting-please/10891.md?page=2)
