Shop OBEX P1 Docs P2 Docs Learn Events
Smart Pin DC Motor Control Demo — Parallax Forums

Smart Pin DC Motor Control Demo

JonnyMacJonnyMac Posts: 9,104
edited 2020-03-15 21:15 in Propeller 2
Look, Mom, no cogs! Easy-peasy DC motor control with smart pins.

Setup:
pub start(a, b, en, enlevel, freq) | x

'' Start dc motor driver
'' -- a and b are motor control (pwm) pins
'' -- en is the motor enable/coast pin (-1 if not used)
'' -- enlevel is enable pin level (0 or 1) to activate h-bridge outputs
'' -- freq is pwm frequency

  longmove(@mtra, @a, 3)                                        ' copy pins
  enstate := (enlevel) ? 1 : 0                                  ' fix enable pin output level
  x := 100_0 << 16                                              ' set period to 100_0 units
  x |= 1 #> ((clkfreq / 100_0) / freq) <# $FFFF                 ' set timing of 1 unit
  pinstart(mtra, SP_PWM, x, 0)                                  ' set mtra pin to pwm, duty = 0
  pinstart(mtrb, SP_PWM, x, 0)                                  ' set mtrb pin to pwm, duty = 0
  set_enable(false)
Edit: Added enable pin output level.

Use:
pub set_speed(speed)

'' Set motor speed in 0.1% increments (-100_0 to 100_0)

  speed := -100_0 #> speed <# 100_0                             ' limit range

  if (speed < 0)                                                ' reverse
    wypin(mtra, 0)                                              ' - a pin low
    wypin(mtrb, abs speed)                                      ' - pwm on b pin

  elseif (speed == 0)                                           ' stop
    wypin(mtra, 0)                                              ' - both pins low
    wypin(mtrb, 0)

  else { speed > 0 }                                            ' forward
    wypin(mtra, speed)                                          ' - pwm on a pin
    wypin(mtrb, 0)                                              ' - b pin low

  set_enable(true)                                              ' h-bridge outputs active
Edit: Updated comments

Note: Some files in archive require PNut v34n.

Comments

  • JonnyMac wrote: »
    Easy-peasy DC motor control with smart pins.

    :neutral:


    Bill M.

    Maybe it is just me, but IMO comments are short,
    maybe terse for something so new.

    Why can't Parallax use common terminology like
    frequency in Khz, duty cycle, etc.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-15 06:15
    I tend to be concise with my comments -- I'm not one to go overboard with fluff, and I refuse to include a full-blown tutorial in my objects (this was actually requested by a person who refused to crack open a data sheet).

    This is my first crack at this object, and I probably will bolster the comments when I can think of the right -- concise -- commentary.

    Your turn. Please do what I did: sit at your desk, 'scope connected to the Propeller 2, then write, debug, and post an object demonstrating some new feature of the P2 in a ready-to-use form that others can put to use. I look forward to seeing your style -- I just may adopt some it if the comments are concise, useful, and meet my strict aesthetic requirements. I work in Hollywood where formatted documents (scripts, in particular) have very strict rules; I treat my program listings with the same seriousness.

    Can't wait to see your thread.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2020-03-15 08:00
    I know who you are, and who you are not.

    I criticized this one code example, not your past work.

    I assume the object was written for a L293 ic.

    I noticed you used some of the same terminology that Parallax
    used in the P2, Spin2 manuals. Parallax has used many (new to me)
    terms or names to describe P2 pin functions.

    I am criticizing your title and the comments to this piece of code,
    "terse for something so new." I was referring to how you are setting
    up the smart pins.

    I understood your code comments, but not how you set-up the pins
    other than you chose "Saw Tooth" mode and that you were modifying
    the "_PPPPPPPPPPPPP_" portion of the smart pin register.
    ''  jm_motor_testing.spin2
    
    con { io pins }
    
      RX1   = 63  { I }
      TX1   = 62  { O }
    
      MTR_E = 56  { O }
      MTR_B = 41  { O }
      MTR_A = 40  { O }
    
    pub setup()
    
      term.start(BR_TERM)
      mtr.start(MTR_A, MTR_B, MTR_E, 20_000)
    
    ''  jm_motor.spin2
    
    con
    
      SP_PWM = %0000_0000_000_0000000000000_01_01001_0              ' smart pin mode
    
    pub start(a, b, en, freq) | x
    
    '' Start dc motor driver
    '' -- a and b are motor control (pwm) pins
    '' -- en is the motor enable/coast pin (-1 if not used)
    '' -- freq is pwm frequency
    
      longmove(@mtra, @a, 3)                                         ' copy pins
      x := 100_0 << 16                                                 ' set period to 100_0 units
      x |= 1 #> ((clkfreq / 100_0) / freq) <# $FFFF                ' set timing of 1 unit
      pinstart(mtra, SP_PWM, x, 0)                                  ' configure motor pins
      pinstart(mtrb, SP_PWM, x, 0)
      set_enable(false)
    

    Bill M.


    BTW: I have a jm_xxxx.spin collection, I use your code as a reference,
    I purchased an online subscription to Nuts n Volts just so that I can
    access to your SX and Propeller articles.
  • For the record Jon ... I have been modeling your code style since the BS1 days. :-)
  • evanhevanh Posts: 15,916
    edited 2020-03-15 08:10
    Bill,
    I've been slowly building up some constants for the WRPIN pin config instruction for a while now. Here's the complete smartpin mode list:
    ' Smartpin modes
    	SP_OUT		= (%1 << 6)		' enable digital output when DIR operates smartpin
    
    	SPM_OFF		= 0				' smart pin off (default)
    	SPM_REPOSITORY	= %00001_0			' long repository (P[12:10] != %101)
    
    	SPM_DAC_RANDOM	= %00001_0 |SP_OUT|PM_DAC	' DAC noise (P[12:10] = %101)
    	SPM_DAC_RND	= %00010_0 |SP_OUT|PM_DAC	' DAC 16-bit dither, noise (P[12:10] = %101)
    	SPM_DAC_PWM	= %00011_0 |SP_OUT|PM_DAC	' DAC 16-bit dither, PWM (P[12:10] = %101)
    
    	SPM_PULSES	= %00100_0 |SP_OUT		' pulse/cycle output
    	SPM_STEPS	= %00101_0 |SP_OUT		' transition output
    	SPM_NCO_FREQ	= %00110_0 |SP_OUT		' NCO frequency
    	SPM_NCO_DUTY	= %00111_0 |SP_OUT		' NCO duty
    	SPM_PWM_TRI	= %01000_0 |SP_OUT		' PWM triangle
    	SPM_PWM_SAW	= %01001_0 |SP_OUT		' PWM sawtooth
    	SPM_PWM_SAW_FB	= %01010_0 |SP_OUT		' PWM switch-mode power supply, V and I feedback
    
    	SPM_CNT_QUAD	= %01011_0		' count: A-B quadrature encoder
    	SPM_CNT_UP_ENA	= %01100_0		' count: A clock up, B enable
    	SPM_CNT_DIR	= %01101_0		' count: A clock, B direction
    	SPM_CNT_UP	= %01110_0		' count: (Y=%0) A clock up
    	SPM_CNT_UP_DN	= %01110_0		' count: (Y=%1) A clock up, B clock down
    	SPM_ACC_UP	= %01111_0		' accumulate: (Y=%0) A up
    	SPM_ACC_UP_DN	= %01111_0		' accumulate: (Y=%1) A up, B down
    	SPM_TIM_STEP	= %10000_0		' interval: of most recent step duration
    	SPM_TIM_PULSE	= %10001_0		' interval: of most recent pulse duration
    	SPM_TIM_MANY	= %10010_0		' interval: (Y=%0xx) of X number of accum/pulses/steps
    	SPM_TIMEOUT	= %10010_0		' interval: (Y=%1xx) since most recent high/rise/edge, with X compare
    	SPM_TIM_PULS	= %10011_0		' interval: of X number of A-B pulses/steps
    	SPM_ACC_PULS	= %10100_0		' accumulate: pulses/steps, of X number of A-B pulses/steps
    	SPM_TIM_OVER	= %10101_0		' interval: of A-B pulses/steps, for at least X duration
    	SPM_ACC_OVER	= %10110_0		' accumulate: A-B pulses/steps, for at least X duration
    	SPM_CNT_OVER	= %10111_0		' count: A-B pulses/steps, for at least X duration
    
    #ifdef PROP2_REVA
    	SPM_USB_HOSTL	= %11000_0 |SP_OUT		' USB host, low-speed (even/odd pin pair = DM/DP)
    	SPM_USB_HOSTH	= %11001_0 |SP_OUT		' USB host, high-speed (even/odd pin pair = DM/DP)
    	SPM_USB_DEVL	= %11010_0 |SP_OUT		' USB device, low-speed (even/odd pin pair = DM/DP)
    	SPM_USB_DEVH	= %11011_0 |SP_OUT		' USB device, high-speed (even/odd pin pair = DM/DP)
    #endif
    #ifdef PROP2_REVB
    	SPM_ADC_ISINC	= %11000_0			' ADC sample/filter/capture, internally clocked
    	SPM_ADC_ESINC	= %11001_0			' ADC sample/filter/capture, externally clocked
    	SPM_ADC_SCOPE	= %11010_0			' ADC scope-mode, with trigger, internally clocked
    
    	SPM_USB		= %11011_0 |SP_OUT		' USB v1.0 host or device, (even/odd pin pair = DM/DP)
    #endif
    	SPM_SSER_TX	= %11100_0 |SP_OUT		' sync serial transmit (A-data, B-clock)
    	SPM_SSER_RX	= %11101_0			' sync serial receive (A-data, B-clock)
    	SPM_ASER_TX	= %11110_0 |SP_OUT		' async serial transmit (baud)
    	SPM_ASER_RX	= %11111_0			' async serial receive (baud)
    
    	SSTX_STOP	= (%1 << 5)			' sync serial transmit first bit direct when empty (start-stop mode)
    	SSRX_LATE	= (%1 << 5)			' sync serial receiver post-clock sampling
    
    
    There is only a few parameter constants defined for those smartpin modes. Lots more to do there.


    And here's just some of the pin modes. The ones I've been using.
    ' Pin modes
    '   ***********************************************************
    '   ***** PIN MODES INCOMPLETE ***** ONLY HAS WHAT I USED *****
    '   ***********************************************************
    	P_REGD		= (%1 << 16)		' turn on clocked digital I/O (registered pins)
    	P_IINV		= (%1 << 15)		' invert digital input
    	P_OINV		= (%1 << 14)		' invert digital output
    	P_FB_A		= (%0001 << 17)		' feedback, inA -> out
    	P_FB_B		= (%0010 << 17)		' feedback, inB -> out
    
    	P_FLOAT		= (%111111 << 8)	' float digital output
    	P_1K5R		= (%001001 << 8)	' 1.5 kiloOhm digital output
    	P_15KR		= (%010010 << 8)	' 15 kiloOhm digital output
    	P_1mA		= (%100100 << 8)	' 1 milliAmp digital output
    
    	P_COGDAC	= (%01 << 6)		' select a cog/streamer for DAC level, smartpin must be off
    	P_BITDAC	= (%10 << 6)		' preset for DAC level (split in revB), smartpin off (default for smartpins when DACMODE)
    
    	PM_DAC		= (%101 << 18)		' DAC output (with optional ADC input), preset level
    	PM_DAC_990	= PM_DAC |(%00 << 16)	' 990 Ohm, 3.3 Volt range
    	PM_DAC_124	= PM_DAC |(%10 << 16)	' 124 Ohm, 3.3 Volt range
    	PM_DAC_600	= PM_DAC |(%01 << 16)	' 600 Ohm, 2.0 Volt range
    	PM_DAC_75	= PM_DAC |(%11 << 16)	' 75 Ohm, 2.0 Volt range
    
    	PM_COMPDAC	= (%1100 << 17)		' Analogue comparator with DAC as preset reference
    
    	PM_ADC		= (%100 << 18)		' turn on custom pin ADC input
    	PM_ADC_GIO	= PM_ADC | (%000 << 15)
    	PM_ADC_VIO	= PM_ADC | (%001 << 15)
    	PM_ADC_B1	= PM_ADC | (%010 << 15)
    	PM_ADC_A1	= PM_ADC | (%011 << 15)
    	PM_ADC_A3	= PM_ADC | (%100 << 15)
    	PM_ADC_A10	= PM_ADC | (%101 << 15)
    	PM_ADC_A30	= PM_ADC | (%110 << 15)
    	PM_ADC_A100	= PM_ADC | (%111 << 15)
    
    
    	AF_PLUS1	= (%0001 << 28)
    	AF_PLUS2	= (%0010 << 28)
    	AF_PLUS3	= (%0011 << 28)
    	AF_MINUS1	= (%0111 << 28)
    	AF_MINUS2	= (%0110 << 28)
    	AF_MINUS3	= (%0101 << 28)
    	AF_OUT		= (%0100 << 28)
    	AF_NOT		= (%1000 << 28)
    	AF_PLUS1NOT	= (%1001 << 28)
    	AF_PLUS2NOT	= (%1010 << 28)
    	AF_PLUS3NOT	= (%1011 << 28)
    	AF_MINUS1NOT	= (%1111 << 28)
    	AF_MINUS2NOT	= (%1110 << 28)
    	AF_MINUS3NOT	= (%1101 << 28)
    	AF_OUTNOT	= (%1100 << 28)
    
    	BF_PLUS1	= (%0001 << 24)
    	BF_PLUS2	= (%0010 << 24)
    	BF_PLUS3	= (%0011 << 24)
    	BF_MINUS1	= (%0111 << 24)
    	BF_MINUS2	= (%0110 << 24)
    	BF_MINUS3	= (%0101 << 24)
    	BF_OUT		= (%0100 << 24)
    	BF_NOT		= (%1000 << 24)
    	BF_PLUS1NOT	= (%1001 << 24)
    	BF_PLUS2NOT	= (%1010 << 24)
    	BF_PLUS3NOT	= (%1011 << 24)
    	BF_MINUS1NOT	= (%1111 << 24)
    	BF_MINUS2NOT	= (%1110 << 24)
    	BF_MINUS3NOT	= (%1101 << 24)
    	BF_OUTNOT	= (%1100 << 24)
    
    
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-15 17:30
    :neutral:
    Maybe it's just me, but after sitting at my desk all day long, attempting to write something useful that I can share with others to perhaps inspire them to experiment with the P2, I find this "I'm not impressed'" emoji a bit galling. Another direction you could have gone is, "Hey, Jon, that's kind of neat, but I'm a little fuzzy on the details -- could you help me out?" Why do people find it easier so easy to be critics?
    I noticed you used some of the same terminology that Parallax
    used in the P2, Spin2 manuals. Parallax has used many (new to me)
    terms or names to describe P2 pin functions.
    I'm confused. I'm writing P2 code -- why would I not use Parallax terms when it is Parallax documentation that others will use as their official reference?
    I am criticizing your title and the comments to this piece
    of code, "terse for something so new." I was referring to how you are
    setting up the smart pins.
    You're unhappy with "Smart Pin DC Motor Control"? But, that's what I'm doing. It is likely that Chip will create a bunch of named constants that will make listings a little friendlier. If and when he does, I'll use them. If he doesn't I may adopt Evan's or create my own.
    I understood your code comments, but not how you set-up the pins
    other than you chose "Saw Tooth" mode and that you were modifying
    the "_PPPPPPPPPPPPP_" portion of the smart pin register.
    I told Chip that I found the "PWM Sawtooth" notation in the docs confusing -- I'm sure this will be addressed in official documentation. Unless it's a very peculiar set of circumstances, I don't use comments for why I do things, I just detail what I'm doing. I save the "Why I do it this way..." stuff for magazine articles and books. BTW, the motor code does not modify the PWM Sawtooth P field (output is true mode).

    As I said, I will probably bolster my comments in the demo and the object -- I tend to do that as code is settled and not so transitional.
  • evanh wrote: »
    Bill,
    I've been slowly building up some constants for the WRPIN pin config instruction for a while now. Here's the complete smartpin mode list:

    Thanks!

    I started to edit your "Pin Mode" constants so that they
    would fit nicely in a pdf.
  • @JonnyMac Thank you Jon for all the excellent work you have completed. The reference material available from Chip at this time is quite limited, which makes your examples even more valuable.
    Was there a file attached named jm_motor_testing.zip ? I can't see it anymore.
    Please keep producing your examples and posting them on this forum.
    Everything you have posted is 100% ok by me.
    You are the best!
    Kevin.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-15 18:23
    Thanks, Kevin.

    As I told Chip when we spoke yesterday, I'm doing this for myself and for those who might otherwise wait for examples in the final documentation. I've never claimed to be a great programmer, but I always succeed at that tasks I'm given, and my maniacal insistence on neat listings and style seem to resonate with people. I'm happy if code that I've written for myself can benefit others.

    I think we were subjected to a forum glitch. When I first read your message I found the file missing, too. Since Chip released a new version of PNut in the early morning hours, and I added a feature to the motor driver, I went back and rebuilt the archive. When I returned to the forum the original file was there. It's been replaced with the latest.

    Again, thanks for you kind words. Have fun with the P2 -- I certainly am (even if, at moments, not knowing all the details is frustrating).
  • Many thanks Jon,
    Perhaps other postings of yours have lost there attachments. I have not checked.
    I wish to suggest that you always attach the latest version to your most recent posting. Leave the past as is.
    Also you might note in your posting, for example: "My version no. 2 is attached to this posting."
    If future attachments disappear then it will be more noticeable. I believe the glitch really does exist.
    Regards,
    Kevin.
  • With respect, I prefer not to leave outdated code out in the world -- for me, posting only the latest reduces clutter and confusion.

    The glitch is real; forum administrators have had to deal with this from time-to-time.
  • @JonnyMac I can not see your attachment on this thread.
    Kevin.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-15 21:16
    Nor I, but it was there an hour ago when I updated the first post. I re-attached; will be interesting to see if two copies of the same file show up later.
  • I can see the attachment in the first post and it downloads fine. I'll have check the time stamps to see if I got the newer file also.
  • I can't see it now -- and I know with certainty I attached it just before my last comment.
  • Have to agree with JonnyMac, removing the old version when putting up the new one is preferred when it comes to source code. Too easy for people to end up with an obsolete or bad old version otherwise.
  • Especially in the early development days when -- I find -- code changes are frequent as ideas coalesce and mature.
  • Jon, are you on Chrome? I can see the zip file fine and just downloaded a second copy.
  • These are two that I got from the first post. A day apart.
  • Publison,
    I am on Chrome, and I see the zip attached to the first post fine, as well as your two attachments.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-15 23:02
    I'm on Chrome, too, and still can't see the attachment to the first post, even after re-starting Chrome. Tried Firefox and Edge as well; no dice there, either. Hmm....

    I can see @Publison's attachments.
  • Perhaps I can add another clue (weirdness???), in order to help further investigation:

    - just after my lunch (I'm under UTC-3' time, thus, 5 hours ago), I've saw kg1's first post, telling us he couldn't find the attacment;

    https://forums.parallax.com/discussion/comment/1491766/#Comment_1491766

    - I was using my PC (W 8.1, Firefox: 74.0), so I did checked it, and the same problem happened with me: the attachment was not there; I did shut-down my system, and went to take a nap, for a while (too hot here, better spare some meningeal cells for the night-shift);

    - Unfortunatelly, I didn't checked it thru my Android phone, before the long nap;

    - I woke ~45m ago, did a look at the thread, using my phone (Android, Sansung browser (Chrome)), and there was three incarnations of the attachment, one at the first post, and the two Publison did attached to his own post;

    - So I did woke-up my W 8.1 beast, and opened the forum, just to check how it looks like, from my W 8.1 (Firefox) POV: well there are three of them: Jon's at first post, and Publison's two, at his own post.
  • Here's something...

    When clicking the URL link in this format, then Jon's attachment is missing:

    http://forums.parallax.com/discussion/comment/1491796/#Comment_1491796

    However... click the date-time stamp under @JonnyMac name at the top of the post, and the attachment appears.
    That link uses a different structure:

    http://forums.parallax.com/discussion/171321/smart-pin-dc-motor-control-demo


    So the quick fix to make the attachments appear, is click the datetime link.
    I will go add this issue to the "todo" list for the next forum update session.


  • First post is 17xxxx (was 16xxxx until recently), subsequent posts are 14xxxxx.

    I've never been able to edit any of my 16xxxx or 17xxxx posts. When I click on Save Comment, the edited first post is not saved and instead it is written to a new 14xxxxx post at the end of the discussion. This includes just changing thread title.

    Firefox 3.6.28, Win98SE, can't upgrade to any later versions.
  • TonyB_ wrote: »
    Firefox 3.6.28, Win98SE, can't upgrade to any later versions.

    Can't you trashpick or otherwise obtain for free an old computer capable of running XP? Or, have you tried Linux?

  • Hi Jon,

    I also want to chime in and assure you that your work here is really appreciated, and YES your coding style is very neat and it is fun to read your code. IMHO you are a great programmer, even if you do not claim to be one.

    Actually I am teaching some kids out of our neighborhood to program and use some of your code as a example of how to to write readable code.

    I think nobody questioned that chip is a great programmer, but reading his code is no fun at all. It is more torture. Single letter variables should be forbidden and flagged by the compiler, NAMING things is hard but absolutely needed.

    Since I learned programming with the worst wordy language there is (COBOL) I had a hard time to learn to comment code once I switched to different languages. COBOL itself does not need comments much, file with 150,000 lines are common but the source is mostly plain English.

    In my professional career as a programmer I learned the hard way that comments are needed to describe the intend of what is done, not how it is done. It is not just COBOL where I have to look thru decades old code, some programs are like children, you never can get really far away from them, they find you.

    Since about 5 years I am rewriting some stuff I did in the 90's and some of my OWN code I wrote is a complete disaster to me. Sure at the time I wrote it, it was crystal clear to me what (and why) I did it, but now 30 years later? Not sure.

    I found your comment about Hollywood scripts very interesting, I never thought about that but you seem to be right, there is something about formalizing some basic rules like Parallax tried with the (failed?) standard library approach.

    Enjoy!

    Mike
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-17 21:46
    Thanks, Mike.
    Actually I am teaching some kids out of our neighborhood to program and use some of your code as a example of how to to write readable code.
    Wow. I hope my code helps. 90% of what I write is for public consumption, so I do try my best to make it clean, elegant, and clear.
    In my professional career as a programmer I learned the hard way that comments are needed to describe the intend of what is done, not how it is done.
    Point taken. I will look for opportunities to explain things without getting overly verbose, or simply repeating what's in the documentation.
    I found your comment about Hollywood scripts very interesting,
    Hollywood is very strict about script formats because the script drives everything. Before a script gets to a person who can make a decision about buying it, a "reader" runs it through the wringer to see it it meets standards. The sad fact is a lot of good stories do not get told because the writer didn't follow standards. That said, it's easier these days with screenwriting software. Still people bend the rules, and it costs them. The reader assumes that if you can't follow the formatting rules, you probably don't follow American screenplay structure or tell stories very well, either.
    ...there is something about formalizing some basic rules like Parallax tried with the (failed?) standard library approach.
    Well... I was one of those people who looked at those rules ("the gold standard") and after wiping the blood from my eyes just said, "No." Just like a script, to me a program should have a specific look, and that gold standard thing was so visually noisy that I refused to use it. I have my own standard that is documented and will be released in the future with some other written material.
    I think nobody questioned that chip is a great programmer, but reading his code is no fun at all.
    Habits can be difficult to break. This is why what you're doing with the youngsters is so important: if they learn a clean, professional style (not necessarily mine, there are others), they will use this through their programming lives. Some people say to me, "It doesn't have to be neat, I'm the only one looking at it." After that I usually smile, remind them that programming is very often a team endeavor, and then remind them that they're now asking me to look at it and help them find their bugs!

  • What I mostly like on your source code is that you break it down into small units of code. That is something I am very bad at, (COBOL again) so it is not unusual for my code to span multiple pages per method, something one should avoid.

    That is part of the reason I use your code examples, not mine. :smile:

    My own programming style is quite horrible, thankfully I do not have co-workers right now, but when I had, I got yelled at some times, old habits do not leave you easy.

    The current code base I am working on went from VB4 to VB6 then to C#, sometimes I generated code to get things done faster, sure I refactor things when I have to change stuff, but hell, there are monsters hiding in the code I can just attack after 10 hours of night work using the midnight oil keeping me running.

    I do agree with you that the gold standard was uncool, but the basic idea is quite right, just not the way it was proposed.

    Anyways, keep on the good work and get more jm_xxx stuff out here, it is badly needed.

    Thanks,

    Mike
  • Thanks, Mike -- and jm_i2c.spin2 is on the way. Pure Spin2 version is working; at the moment I am converting some of the code to inline PASM2 for clock speed control.
  • jmgjmg Posts: 15,173
    JonnyMac wrote: »
    I told Chip that I found the "PWM Sawtooth" notation in the docs confusing...

    I think that comes from other PWM modes, and historical misnomers...

    The P1 mentions PWM, but that is actually PDM (Pulse Density Modulation), not PulseWidthModulation at all.
    Other MCUs often have two modes of genuine PWM : A PWM sawtooth (Up counting only), and a PWM triangle (up/down counting)
    The triangle mode is useful for where you need dead-bands across multiple PWM channels.


Sign In or Register to comment.