Setting CVs in AccDec_10Servos_7LED_6Ftn

Shdwdrgn Mar 24, 2018

  1. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    I'm using a modified version of this sketch from the Nmra library, and I can't figure how I'm supposed to set a CV. I am working from the command line and would like, for example, to change CV 103. There is a variable in the code that seems to indicate the cab address is 24, and lets say I want to change the value to 64. So in DCC++ I issue the command <w 24 103 64> which should change the maximum value of a servo. Unfortunately this doesn't work and I see nothing returned on the serial console for the accessory arduino.

    Am I missing something? While the functions for handling accessory commands is obvious in the sketch, I see nothing at all to manage setting a CV. Granted the library zip file I pulled from Geoff Bunza's blog is a fairly old version so perhaps the handles for writing CVs were added in later?

    Any help on this would be appreciated. I seem to have everything else working in my modified code but I would really like to be able to change the range of rotation for the servos.
     
  2. Pieter

    Pieter TrainBoard Member

    152
    46
    10
    Most of Goeff's older mini Arduino projects you have to set the values before you program it. In one of his '17 function' update posts there is a description of how to change it including for daisy chaining. This one forms the basis of his projects around servo's & LEDs.
     
  3. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Yeah I've seen the array that holds the 'factory' settings to get things initialized, but you're supposed to be able to change those values once the arduino is up and running. There's also a CV defined that should initiate a reset of the arduino and setting the CVs back to default, and that doesn't do anything either. That CV seems to also be part of the Dcc init function, so even if there's no function within the sketch setting that CV should still be caught by the Nmra library and force an observable reset of the arduino. That's why I wondered if I did something wrong in my <w> command, like perhaps that's not the right command to use here or maybe '24' isn't really the cab number I should be using... I dunno.
     
  4. Pieter

    Pieter TrainBoard Member

    152
    46
    10
    Have a look at his blog SMA13 & 15. It is around there that he has split the project. It was around mid last year I was looking into his servo module and vaguely remember there was a "funny" way you had to set it up for the first time (at least I thought so at the time). Also see his reply to @Peppe further down SMA 13. Have a look at his blog 13, 15 & 20 and the replies below it. Or just mail him or on his blog. He replies to all mails he receives.

    "The decoder can be reset to the original parameters by loading CV 120 with 120 (decimal). This will reset everything including the decoder address, when the push button on the Pro Mini is pushed (reset)" SMA13.
     
  5. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    I had to move CV120 down to a lower value and currently have it on 8, so I should be able to load the value 8 into CV8, restart the arduino, and have it perform a reset of all the CV values... Except it doesn't. None of the CV values are being changed. That's the problem.

    Ah well, I found Geoff's contact and sent him a full description, hopefully he can help troubleshoot. I'm excited about getting this code completed because I'm using a PCA9685 board which drives 16 servos directly, can be daisy-chained to control up to 992 servos, and only uses two wires from the arduino for I2C communication. So my base setup is driving 16 servos plus 16 additional I/O ports off the arduino. I just need to be able to modify the CV values to fine-tune the range of each servo (since there seems to be no consistency in the SG90 servo positions) and then I'll have an accessory controller with a lot of capability built in. Sure I could just write out the whole FactoryDefaultCVs array with my custom values, but then what's the point of even claiming they are CV values if you can't modify them the normal way?
     
  6. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    I've been trying a number of different things while waiting for a reply from Geoff, none of which have gotten me any closer. I even reinstalled his original code but still don't seem to be able to write any CVs to cab 24. I also found a hook for notifyCVAck and added a function that simply puts a comment on the serial console, but that doesn't seem to fire even after successfully calling Dcc.setCV(). I dunno, I can only assume that I'm doing something wrong in trying to write the CV values, but I can't seem to find any leads as to what the problem is.
     
  7. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    In case anyone follows up on this thread at a later date (I really hate unanswered threads!) I finally discovered the problem was actually in the base station code, specifically when writing a CV on the main track. Instead of sending the cab and CV in the packet, it was sending the CV twice. Made a couple minor changes in the code and now everything including my soundtraxx decoder is responding to the CV writes. The info was sent to Atani who is getting the base station code updated. Thanks for the replies!
     
    Atani likes this.
  8. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Does this problem exist in Gregg's Arduino BaseStation code or only with the ported ESP BaseStation code?
     
  9. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    Only on the ESP32 version as far as I know. It was introduced as part of the rewrite of the text protocol handler, it would also not show up if you use the web interface to submit the CV write command.
     
    Jimbo20 likes this.
  10. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    And it only existed when trying to write CVs on the mainline, but writing on the programming track worked fine.
     
    Jimbo20 and Atani like this.

Share This Page