Saturday, June 13, 2020

BC2 with Basic PWM

Hard Lessons Re-Learned

After the I2C was working I moved on to PWM for the motors and the single LED controlled by the PIC32.  This seemed very easy from looking at the examples in the Microchip Harmony Framework.  I used my Digilent Analog Discovery 2 USB device to watch the signal.  These are great devices that can be a 2 ch scope, 16 input logic analyzer, waveform generator, etc.  For looking at signals under 2MHz, this much easier than pulling out my Tek Scope.  See here for more information https://www.analogdiscovery.com/



And here is where the fun began.  The circuit I was testing was a single pin driving a FET with 196 ohm current limiting resistor in the path as shown here.


I was using the Digilent USB device hooked up as logic analyzer.  Nothing would show up at the two pins where the LED connects, J13.  Then using another lead and probing the gate and the source pin on the FET, the expected signal was there.  But on the other side of the current limiting resistor nothing.  After a few hours, it becomes clear this is an open collector driver, of course there will be no signal because it is an open circuit.  I dug up a 330ohm resistor to put across the connector, J13, and still nothing.  So I changed to scope mode and the signal is there.  But since there is a current limiting resistor and I was measuring between the current limiting resistor and the 330ohm, the signal did not return to zero, actually a little over 1V.  So the logic analyzer portion of the Digilent wont work, as one would expect.

Well after a day and half of this, I verified that it all works.  It actually always worked,  I just did not know it.  Next step is to get all 4 motor ports working in forward and reverse and then write a driver for the PWM portion. 

Here is a quick video of the PWM signal incrementing from 5 to 100%, in 1% steps.  The PWM frequency is 20KHz, not sure it needs to be that high.  LEGO seems to use 1150 Hz, but I am afraid that will generate unwanted audio tones.  But that is easily changeable and have setup constants that will do all the necessary arithmetic.  At 20KHz there are 2000 steps with this PIC32, much more resolution that we will ever need.



Friday, June 12, 2020

BC2 and LED Control with I2C

After a successful power up, I moved on to the I2Cbus interface.  On the I2C bus is the LED controller, LP5569, and the USB Power Controller, STUSB4500.  The STUSB4500 was not in ready stock anywhere, so that was a DO NO INSTALL during assembly.  The STUSB4500 is only accessed once and that is during PCB configuration, at least that is the current implementation.  So I built the Harmony 2.0 driver around the LP5569.  What I have now is a very basic driver that does the following:
  • RESET
  • Initialize
  • Configuration (enable/disable)
  • Register Dump
  • Update all PWM registers
  • Basic Write Register
  • Basic Read Register
  • Read/Modify/Write Register
There is still a lot of clean up work and optimization that needs to happen.  This is a standalone program for now, which means it will need to be integrated with the other pieces.  But I am quite happy with the current state.

There were some development issues.  The PICKIT4 does not seem to like MPLAB 4.2 very much.  It would hang occasionally and does not the PIC32 register or SFRs.  Changing back to the PICKIT3, at least solved the register and SFR issue.

The LED control in Brick Controller 2 consists of 10 LED ports.  In the original Brick Controller there were only four LED ports and this was not sufficient.  The LP5569 will control 9 LEDS either individually or in up to 3 RGB groupings.  Port 10 is under direct software control and is connected to a PWM port on the PIC32.  The intention is to have ON/OFF, Burst, Cycle and the PWM functionality on all 10 LED ports, but we will see how this goes.  The LP5569 is a much more capable device with multiple types of controls, but these advanced features will have to wait until the basic BC2 is done.

The next step is implement the PWM features of the PIC32 that will be used with the 4 motor ports and LED port 10.  I will be using LED port 0 as the prototype, since in this implementation it is much easier to observe.

Here is a quick video of a single LED with varying intensity.


Monday, June 8, 2020

BC2 Power Up

After checking for shorts on the PCB and finding none, I applied power.  I suspected it would not work without the USB Power controller and I was correct.  But grounding the control for the P_FET brought 5 VDC to the power section and all the DC-DC converters powered up. 

Then I built the Board Support Package for the Microchip MPLAB X Harmony system.  Finally did a very simple program to blink the BLUE/YELLOW USB connection LEDs that I use in all of the MyMakerTools products.   The result is below.


Next is to build the I2C driver and the application code for the LP5569 LED controller.  I have this mostly done from a previous prototype, but need to convert it to the Harmony structure.

Saturday, June 6, 2020

BC II PCBs have Arrived

Received the Brick Controller II PCBs.  Over the next few days I will be doing the necessary static testing to ensure that 1) I designed it correctly and 2) the manufacturer built it correctly.  Follow the progress here as I test these in conjunction with the MP3/FLASH module. 




Brick Buddy PC Software

Started cleaning up the PC software for the Brick Buddy line of controllers.  One single software package will work for the entire line of Brick Buddys, at least as I see them today.  The PC software will interrogate the attached device and determine what it is and then load the appropriate software options. 

When the software first starts and when no recognizable device attached, then the control center window will show this:


At this point the user needs to connect a Brick Buddy device to the PC.  Once the device is connected, the PC will begin to enumerate the device and determine it's identity.  Once the identity is determined, the window on the PC will expand to show what device is connected, device status and what if any options are available.  This is shown in the figure below.


This change should make it much easier for everyone to use the PC based software to program and control their individual Brick Buddy devices.


Wednesday, June 3, 2020

MP3/FLASH Test Platform (Update 2)



Surprisingly the FLASH portion fired right up and worked.  I am now cleaning up the code.  first step was to correct all the USB descriptors so the Brick Buddy PC software will properly recognize the device.  Since the Brick Controller II will be sold without this module, the firmware had to be modified to only check for the device once and not continually.  Dont need to be wasting PIC32 bandwidth looking for things that are not there.  Other cleanup is needed as I dig into this deeper.  But next I am going to modify the Brick Buddy PC GUI and software to handle the new controller.

Monday, June 1, 2020

MP3/FLASH Test Platform (Update 1)

The PCBs are assembled as shown below.  The MP3 decoder has not arrived yet, thus I will only be testing the FLASH drive for now. 



More later as we progress with the testing.