fiduciary

Author Topic: TeensySaber Software Discussion  (Read 67076 times)

0 Members and 3 Guests are viewing this topic.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #60 on: June 18, 2017, 12:30:52 PM »
So this is now what happens if you boot up a teensysaber without an SD card:




Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #61 on: June 18, 2017, 12:51:38 PM »
I am trying to compile v1.119 for the Teensy 3.5 and I'm getting the following errors...

....

The same code compiles fine when I select the Teensy 3.2 board. 

I haven't been able to figure out why.  Any ideas?

The Teensy 3.5 doesn't support touch buttons, and it would seem my code doesn't like that.
I will fix it.

The version on github should now compile on Teensy 3.5.
I will be uploading to my site in a few days or so.
Note that the new version is split up into multiple files.


Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #62 on: June 18, 2017, 01:35:19 PM »
So this is now what happens if you boot up a teensysaber without an SD card:



That is a nice addition. I have forgot to put my SD card in a couple times so that will help :)

Great work.

How is the testing of the Teensyduino beta going ? Is the MTP working out as expected ?

Regards,

GMcIvor
« Last Edit: June 18, 2017, 02:52:17 PM by gmcivor »

Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #63 on: June 19, 2017, 12:32:26 PM »
I have a question, in the code how do I change the sensitivity of the clash? In my students saber, we have secured the chassis, nothing is moving or shaking, every time we swing soft it will swing. But if we swing it harder it will clash instead. I thought the chassis would be moving but we have secured it in several places fixing that issue.

It is the first time I have done the V2 electronics so maybe I need to redesign the chassis for them... Which I am currently doing. Will make it easier to program as the whole back half will come out leaving the button assembly in place.

Regards,

GMcIvor

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #64 on: June 19, 2017, 12:44:22 PM »
I have a question, in the code how do I change the sensitivity of the clash? In my students saber, we have secured the chassis, nothing is moving or shaking, every time we swing soft it will swing. But if we swing it harder it will clash instead. I thought the chassis would be moving but we have secured it in several places fixing that issue.

It is the first time I have done the V2 electronics so maybe I need to redesign the chassis for them... Which I am currently doing. Will make it easier to program as the whole back half will come out leaving the button assembly in place.

Regards,

GMcIvor

The V2 seems to be more sensitive than the V1 for some reason. Maybe because it samples at a higher speed?
Either way, the threshold lives in Saber::SB_Accel, in a line that looks like this:
Code: [Select]
if ( (accel_ - accel).len2() > 1.0) {

The 1.0 is the limit in g squared. Try a higher value, like maybe 2.0 ?

Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #65 on: June 19, 2017, 12:49:09 PM »
I have a question, in the code how do I change the sensitivity of the clash? In my students saber, we have secured the chassis, nothing is moving or shaking, every time we swing soft it will swing. But if we swing it harder it will clash instead. I thought the chassis would be moving but we have secured it in several places fixing that issue.

It is the first time I have done the V2 electronics so maybe I need to redesign the chassis for them... Which I am currently doing. Will make it easier to program as the whole back half will come out leaving the button assembly in place.

Regards,

GMcIvor

The V2 seems to be more sensitive than the V1 for some reason. Maybe because it samples at a higher speed?
Either way, the threshold lives in Saber::SB_Accel, in a line that looks like this:
Code: [Select]
if ( (accel_ - accel).len2() > 1.0) {

The 1.0 is the limit in g squared. Try a higher value, like maybe 2.0 ?

I will give that a try, thank you!



Regards,

GMcIvor
« Last Edit: June 19, 2017, 01:44:04 PM by gmcivor »

Offline gmcivor

  • Force User
  • ***
  • Posts: 140
  • Do or do not. There is no try.
Re: TeensySaber Software Discussion
« Reply #66 on: June 19, 2017, 01:44:54 PM »
Well I had to change it to 3 and it was alot better, still happens now and again. She is super happy now.

Thank you :)

Regards,

GMcIvor

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #67 on: June 20, 2017, 10:26:30 AM »
TeensyDuino 1.37 has just been released, which adds "MTP Disk (experimental)" in the USB type menu.
Using this option will enable MTP in TeensySaber and let you upload/download files to the SD card without removing it.
It should work without any extra drivers on Windows and Linux, but may require some extra installs on Mac.
I know a few people are using the serial flash chip on the prop shield instead of an SD card. Currently the MTP code does not support uploading/downloading to the serialflash chip, but I intend to fix that.

Offline Obi-Ken Wanobi

  • No Force
  • *
  • Posts: 48
  • Help me Obi-Ken... you're my only hope.
Re: TeensySaber Software Discussion
« Reply #68 on: June 20, 2017, 10:40:10 AM »
The version on github should now compile on Teensy 3.5.
I will be uploading to my site in a few days or so.
Note that the new version is split up into multiple files.

I pulled the version from github and spent some time tailoring it.  I was able to get it to compile and load to my Teensy 3.5 electronics.  I do however have an issue.  When I signal a power off of the blade my "pwroff01.wav" file does not play.  Power on, hum, clash, swing, etc. all seem to work but power off doesn't.

Please note I am testing this on a bench with NO blade connected.  I don't even have the N-channel MOSFETs attached yet.  I'm not sure that this would make a difference.

Based on the sound playing I can obviously access the SDcard and the soundfont loaded under folder "font1".  I can even play the "font1/pwroff01.wav" file through the Serial Monitor commands but it doesn't play when I power off (even using the "pow" command). 

Offline Obi-Ken Wanobi

  • No Force
  • *
  • Posts: 48
  • Help me Obi-Ken... you're my only hope.
Re: TeensySaber Software Discussion
« Reply #69 on: June 20, 2017, 10:54:15 AM »
The version on github should now compile on Teensy 3.5.
I will be uploading to my site in a few days or so.
Note that the new version is split up into multiple files.
I found I still needed to tailor some items in the main lightsaber.ino file so I decided to do a little work to make these remaining items options in the "config" header file. Here's what I changed to enable the builtin SD on the Teensy 3.5...
#ifdef ENABLE_BUILTIN_SDCARD
  sdCardSelectPin = BUILTIN_SDCARD,  // SD card chip (sd card adapter)
                                     // Set to BUILTIN_SDCARD for Teensy 3.5/3.6
                                     // (See File->Example->SD->ReadWrite for
                                     // other possible values.)
#else
  sdCardSelectPin = 0,
#endif


I then added the following to the "config" header file...
// If you are using a Teensy 3.5/3.6 built-in SD card reader define this.
#define ENABLE_BUILTIN_SDCARD 


While I was in the saber pins section I noticed a comment about the Wiz820+SD so I made the following change...
#ifdef ENABLE_WIZ820SD
  freePin4 = sdCardSelectPin,     // FREE (make this sdCardSelectPin if you're using a Wiz820+SD shield)
#else
  freePin4 = 4,                   // FREE (make this sdCardSelectPin if you're using a Wiz820+SD shield)
#endif


and I added the following to the "config" header file...
// If you are using a Wiz820+SD uncomment the #define ENABLE_WIZ820SD
// #define ENABLE_WIZ820SD


I then added the following to support specifying a different value for the external pullup resistor in your v1 electronics...
#if VERSION_MAJOR >= 2
    float pulldown = 220000;  // External pulldown
    float pullup = 2000000;  // External pullup
#else
    float pulldown = 33000;  // Internal pulldown is 33kOhm
#ifdef EXTERNAL_PULLUP_VALUE
    float pullup = EXTERNAL_PULLUP_VALUE;  // External pullup value from config header file
#else
    float pullup = 23000;  // External pullup
#endif
#endif


and the following to the "config" header file...
// If you are using an external pullup resistor value other that 23K on your v1 electronics, define the value here.
// #define EXTERNAL_PULLUP_VALUE yourvaluehere


Let me know what you think.
« Last Edit: June 20, 2017, 11:04:43 AM by Obi-Ken Wanobi »

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #70 on: June 20, 2017, 11:31:55 AM »
I don't want to put too much in the config files, so uncommon configuration options should probably still require changing lightsaber.ino.
Of the changes you listed, I think the WIZ820SD definitely falls into that category.
As for the sd card change, I've been considering ways to add some ways to override the pin map in the config file, so that you could change things in the pin map *if you want to*.  Using ifdefs for every possible pin map is probably going to make the code really hard to read. However, until I've figure out the right way to do that, ENABLE_BUILTIN_SDCARD might be an ok solution. Maybe the simplest option would be to just move the pin map to the config file...


Offline Obi-Ken Wanobi

  • No Force
  • *
  • Posts: 48
  • Help me Obi-Ken... you're my only hope.
Re: TeensySaber Software Discussion
« Reply #71 on: June 20, 2017, 12:03:17 PM »
I don't want to put too much in the config files, so uncommon configuration options should probably still require changing lightsaber.ino.
Of the changes you listed, I think the WIZ820SD definitely falls into that category.
As for the sd card change, I've been considering ways to add some ways to override the pin map in the config file, so that you could change things in the pin map *if you want to*.  Using ifdefs for every possible pin map is probably going to make the code really hard to read. However, until I've figure out the right way to do that, ENABLE_BUILTIN_SDCARD might be an ok solution. Maybe the simplest option would be to just move the pin map to the config file...

I was looking at it from the perspective of trying to avoid modifying the main lightsaber.ino file each time you release a new version.  I would think the main options should be housed in the "config" file while those odd, "one offs" could stay in the main code.  This would include the things that would change if you were running on different Teensy boards, etc.  I also included the external pullup resistor because I ended up using a 22K resistor instead of a 23K and I took a reading on them before installing them.  I ended up with a value of 21,800 which was enough of a difference to throw off the battery level values.  I would also think things like sound volume and sensitivity settings for clash and swing should be something that can be specified in the config file.

Just my humble opinion.   :grin:

Oh and btw... nice work on the voice coding.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #72 on: June 20, 2017, 12:36:31 PM »
I don't want to put too much in the config files, so uncommon configuration options should probably still require changing lightsaber.ino.
Of the changes you listed, I think the WIZ820SD definitely falls into that category.
As for the sd card change, I've been considering ways to add some ways to override the pin map in the config file, so that you could change things in the pin map *if you want to*.  Using ifdefs for every possible pin map is probably going to make the code really hard to read. However, until I've figure out the right way to do that, ENABLE_BUILTIN_SDCARD might be an ok solution. Maybe the simplest option would be to just move the pin map to the config file...

I was looking at it from the perspective of trying to avoid modifying the main lightsaber.ino file each time you release a new version.  I would think the main options should be housed in the "config" file while those odd, "one offs" could stay in the main code.  This would include the things that would change if you were running on different Teensy boards, etc.  I also included the external pullup resistor because I ended up using a 22K resistor instead of a 23K and I took a reading on them before installing them.  I ended up with a value of 21,800 which was enough of a difference to throw off the battery level values.  I would also think things like sound volume and sensitivity settings for clash and swing should be something that can be specified in the config file.

Just my humble opinion.   :grin:

Oh and btw... nice work on the voice coding.

Yeah, we're basically agreeing. I just want to make sure we keep the config files short and easy to use as well.
And I totally agree that sensitivity settings should be in the config file.
I will be incorporating all of these changes (except for the wiz820sd change) into the code.
(And I might try to do something else for the sd card pin.)


Offline Obi-Ken Wanobi

  • No Force
  • *
  • Posts: 48
  • Help me Obi-Ken... you're my only hope.
Re: TeensySaber Software Discussion
« Reply #73 on: June 20, 2017, 01:57:26 PM »
I pulled the version from github and spent some time tailoring it.  I was able to get it to compile and load to my Teensy 3.5 electronics.  I do however have an issue.  When I signal a power off of the blade my "pwroff01.wav" file does not play.  Power on, hum, clash, swing, etc. all seem to work but power off doesn't.

Please note I am testing this on a bench with NO blade connected.  I don't even have the N-channel MOSFETs attached yet.  I'm not sure that this would make a difference.

Based on the sound playing I can obviously access the SDcard and the soundfont loaded under folder "font1".  I can even play the "font1/pwroff01.wav" file through the Serial Monitor commands but it doesn't play when I power off (even using the "pow" command).

I'm not sure if you saw this earlier post.  For some reason I can't get the "power off" sound to work with the latest commit on github.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 901
  • May the source be with you.
    • Hubbe's Corner
Re: TeensySaber Software Discussion
« Reply #74 on: June 20, 2017, 02:25:52 PM »
I pulled the version from github and spent some time tailoring it.  I was able to get it to compile and load to my Teensy 3.5 electronics.  I do however have an issue.  When I signal a power off of the blade my "pwroff01.wav" file does not play.  Power on, hum, clash, swing, etc. all seem to work but power off doesn't.

Please note I am testing this on a bench with NO blade connected.  I don't even have the N-channel MOSFETs attached yet.  I'm not sure that this would make a difference.

Based on the sound playing I can obviously access the SDcard and the soundfont loaded under folder "font1".  I can even play the "font1/pwroff01.wav" file through the Serial Monitor commands but it doesn't play when I power off (even using the "pow" command).

I'm not sure if you saw this earlier post.  For some reason I can't get the "power off" sound to work with the latest commit on github.

Sorry, missed it before.
I think maybe you want the "poweroff" sound. If I remember correctly "pwroff" is meant to be the opposite of the "boot" sound, and is not supported. (Although I suppose it could be supported with a large enough capacitor somewhere....)


 

retrousse