MicroMod Beta Testing

It should be interesting! Will be fun to see what your adapter is:
I (and @mjs513) ordered a ribbon adapter from Amazon:
https://smile.amazon.com/gp/product/B07RWMSVNH

Will be fun to play along, once I get to town (probably tomorrow)...

It will be interesting to see how close this camera is to working like the OV7670... The code I had working with DMA using GPIO is up at:
https://github.com/arduino-libraries/Arduino_OV767X
Which started the MClk in a similar way:
Code:
void OV767X::beginXClk()
{
  // Generates 8 MHz signal using PWM... Will speed up.
  analogWriteFrequency(_xclkPin, 16000000);
  analogWrite(_xclkPin, 127); delay(100); // 9mhz works, but try to reduce to debug timings with logic analyzer

}
It will be interesting to see if this camera can be configured like we can on the OV7670 that the PIXCLK to only run when inside HSYNC..

But that document you posted looks interesting for FlexIO.

@KurtE - @PaulStoffregen
Couldn't sleep so I started doing a conversion of the HM01b0 lib I found on the OpenMV website. Funny thing is I have actually played with their stuff and had it hooked up to a Teensy :) Anyway between what @KurtE did and the setup code in post #120 looks like getting closer to capture an image and display it. Attaching what I have so far.

TODO list for me anyway is to: (1) flesh out the lib (.h and add setting the clock divider) (2) add headers to the machine learning board or just go with the ATP board and (3) try and roll some of Kurt's OV7670 camera code to display a BMP :).
 

Attachments

  • HB01b0.zip
    7 KB · Views: 49
@mjs513 I now have my nice new shiny MM plugged into my PC and it is blinking its little blue led...

Do you have a sketch for that zip file?

Looks like I need to do some soldering! And @defragster that camera is Small!

Need to catch up!

Is there an update to Tycommander?

Update to Teensy Tools set? Probably not hard. Will hack up now.

What other things do I need to sync up on...
 
@mjs513 I now have my nice new shiny MM plugged into my PC and it is blinking its little blue led...

Do you have a sketch for that zip file?

Looks like I need to do some soldering! And @defragster that camera is Small!

Need to catch up!

Is there an update to Tycommander?

Update to Teensy Tools set? Probably not hard. Will hack up now.

What other things do I need to sync up on...

No sketch - hopefully later today. Just finished my initial cut at a lib and was planning on working on the sketch next. Got side tracked with the 2 covid shot. And they are still working on the roof. Should be finished today though.

So far from my testing had to do nothing unique except maybe add TEENSYMM - like in MTP . Also had to add the recipe for MTP serial to local boards.txt file.

Have tried @luni's conversion yet to use MM designations. Just been using the normal teens pin. Only exception is to remember is that SDA1 equates to Wire2.

My conversion card has been coming in handy though at least for the basic pinouts:
Picture1.jpg
 
@KurtE: No word from @koromix on update to TyComm to support T.MM - you did it before ... code is 0x26 for T.MM
> That would be great.

Yes, tiny camera module

@mjs512: Pinout 'card' looks handy including note " SDA1 is WIRE2 "
> Does that apply to the twin qwiic's too? One on each it looks like.
 
@mjs512: Pinout 'card' looks handy including note " SDA1 is WIRE2 "
> Does that apply to the twin qwiic's too? One on each it looks like.

Thats on the QWIIC markings and associated header near the QWIIC. SDA = Wire is correct.
 
@mjs513 - incomplete question - and silkscreen read ... ?

There are two qwiic'c on ATP in pic low left and right.

Assume left qwiic is WIRE == i2c, and right qwiic is pulling from those pins as WIRE2 == SDA1 == i2c1
And WIRE1 would be in on shared pins 16/17
 
@mjs513 @defragster. The two QWIIC connectors are on two different Wire objects. As you can see in their schematic:
screenshot.jpg
 
@mjs513 @defragster. The two QWIIC connectors are on two different Wire objects. As you can see in their schematic:
...

Good - as it seems from the board : Wire and Wire2 ... once I got enough clarity on the silkscreen and noting the cusp over WIRE1.
 
@KurtE: No word from @koromix on update to TyComm to support T.MM - you did it before ... code is 0x26 for T.MM
> That would be great.
I believe the source code changes are trivial. The difficulty is getting my setup to work again. I think QT library stuff is confused or the like.

May have to start from scratch and see about building a static version of QT5, to link with... Or figure out again what all of the projects and stuff need to be edited...
 
I believe the source code changes are trivial. The difficulty is getting my setup to work again. I think QT library stuff is confused or the like.

May have to start from scratch and see about building a static version of QT5, to link with... Or figure out again what all of the projects and stuff need to be edited...

Not seen email reply - just made an issue as I should have : Koromix/tytools/issues/75
 
Not seen email reply - just made an issue as I should have : Koromix/tytools/issues/75

I just pushed up some changes that I can not build yet... But I think it has most if not all of the changes need in TyTools.

I also added a line to the Teensy_loader_cli code for the MicroMod. Again I have not tested it yet as the makefile does not work on my windows machine,
I will probably try it on another machine either linux or MAC to see if it works there.

https://github.com/KurtE/teensy_loader_cli/tree/MicroMod
If it does will do PR...
 
@mjs513 I now have my nice new shiny MM plugged into my PC and it is blinking its little blue led...

Do you have a sketch for that zip file?

Looks like I need to do some soldering! And @defragster that camera is Small!

@KurtE - @PaulStoffregen and etal
For anyone interested I have the beginnings of both the library and the test sketch for the Teensy along with the HB01b0 camera. Really wish there was better documentation to go along with it but maybe have to look at the driver more. Right now looks like I can set the FrameRate and FrameSize (320x320, QVGA and QQVGA) - kind of tested that. Using Paul's sketch as the based I modified it use the lib plus my 2 test commands just to see what it would do to synch - well it not can be set to run at 15, 30, 60 FPS. It calculates that based on the framesize parameter.

In openness the library is just a port from the OpenMV HB01B0 driver which has a MIT license so all credit goes to them.

One of the things I did find by poking around the 2 drivers (Sparkfun and OpenMV) is the you can tell the camera how many frames to send at a time by setting the mode:
Code:
uint8_t HM01B0::set_mode(uint8_t Mode, uint8_t FrameCnt)
{
	uint32_t Err;
	
    if (Mode == HIMAX_MODE_STREAMING_NFRAMES)
    {
        Err = cameraWriteRegister(PMU_AUTOSLEEP_FRAMECNT, FrameCnt);
    }

    if(Err != 0)
    {
        Err = cameraWriteRegister(MODE_SELECT, Mode);
    }

    return Err;
}
or you can set the mode to just send one frame using the trigger pin.

Now I stuck at reading the data using the 8-bit parallel ports to get the data for 1 line. Know its on the forum but think getting tired now. This is from the OpenMV repository for capturing a frame. Most of it I can cover but I am lost on this:
Code:
    uint32_t ulPin = 32; // P1.xx set of GPIO is in 'pin' 32 and above
    NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&ulPin);
Note this is reading in the 8-bit data. Here is the whole function if you are interested:
Code:
// This is the default snapshot function, which can be replaced in sensor_init functions.
int sensor_snapshot(image_t *image, uint32_t flags)
{
    uint8_t *b = MAIN_FB()->pixels;
    uint32_t _width  = MAIN_FB()->w;
    uint32_t _height = MAIN_FB()->h;
    int bytesPerRow  = _width * 2; // Always read 2 BPP
    bool _grayscale = (sensor->pixformat == PIXFORMAT_GRAYSCALE);

    uint32_t ulPin = 32; // P1.xx set of GPIO is in 'pin' 32 and above
    NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&ulPin);

    // Compress the framebuffer for the IDE preview, only if it's not the first frame,
    // the framebuffer is enabled and the image sensor does not support JPEG encoding.
    // Note: This doesn't run unless the IDE is connected and the framebuffer is enabled.
    framebuffer_update_jpeg_buffer(NULL);

    noInterrupts();

    // Falling edge indicates start of frame
    while ((*_vsyncPort & _vsyncMask) == 0); // wait for HIGH
    while ((*_vsyncPort & _vsyncMask) != 0); // wait for LOW

    for (int i = 0; i < _height; i++) {
        // rising edge indicates start of line
        while ((*_hrefPort & _hrefMask) == 0); // wait for HIGH
            
        for (int j = 0; j < bytesPerRow; j++) {
            // rising edges clock each data byte
            while ((*_pclkPort & _pclkMask) != 0); // wait for LOW

            uint32_t in = port->IN; // read all bits in parallel
            //in = (in >> 8) | ((in>>2) & 3);
            in >>= 2; // place bits 0 and 1 at the "bottom" of the register
            in &= 0x3f03; // isolate the 8 bits we care about
            in |= (in >> 6); // combine the upper 6 and lower 2 bits

            if (!(j & 1) || !_grayscale) {
                *b++ = in;
            }
            while ((*_pclkPort & _pclkMask) == 0); // wait for HIGH
        }
        while ((*_hrefPort & _hrefMask) != 0); // wait for LOW
    }

    interrupts();

    // Fix the BPP.
    switch (sensor->pixformat) {
        case PIXFORMAT_GRAYSCALE:
            MAIN_FB()->bpp = 1;
            break;
        case PIXFORMAT_YUV422:
        case PIXFORMAT_RGB565: {
            MAIN_FB()->bpp = 2;
            if (SENSOR_HW_FLAGS_GET(sensor, SWNSOR_HW_FLAGS_RGB565_REV)) {
                unaligned_memcpy_rev16(MAIN_FB()->pixels, MAIN_FB()->pixels, _width*_height);
            }
            break;
        }
        case PIXFORMAT_BAYER:
            MAIN_FB()->bpp = 3;
            break;
        default:
            MAIN_FB()->bpp = -1;
            break;
    }

    // Set the user image.
    if (image != NULL) {
        image->w = MAIN_FB()->w;
        image->h = MAIN_FB()->h;
        image->bpp = MAIN_FB()->bpp;
        image->pixels = MAIN_FB()->pixels;
    }
    return 0;
}

Oh - am attaching the example and library for your entertainment.

EDIT: Poked around the forum because I know I saw it: https://forum.pjrc.com/threads/57698-Parallel-IO-is-it-possible?p=216501&viewfull=1#post216501 from @vjmuzik might be what I need. But I am kind of done for the night as I think the my shot is beginning to kick in a little bit.
 

Attachments

  • HM01B0.zip
    10 KB · Views: 43
Last edited:
I just pushed up some changes that I can not build yet... But I think it has most if not all of the changes need in TyTools.

I also added a line to the Teensy_loader_cli code for the MicroMod. Again I have not tested it yet as the makefile does not work on my windows machine,
I will probably try it on another machine either linux or MAC to see if it works there.

https://github.com/KurtE/teensy_loader_cli/tree/MicroMod
If it does will do PR...
Qt builds now. Will test tomorrow. Need to change build to release instead of debug
 
Now I stuck at reading the data using the 8-bit parallel ports to get the data for 1 line

I probably misinterpret your post. But just in case: the MM parallel port (G0-G7) is mapped to consecutive pins on GPIO7, starting at bit4. So, reading / writing a byte to it should be simple. Here how I did it (no chance to test it yet but defragster thankfully did some tests)

https://github.com/luni64/TeensyHel...841bc10812685/src/MicroMod/MicroModT4.cpp#L13

Usage:
Code:
   // writing to the 8bit port (G0-G7):
  mmBus.pinMode(OUTPUT);  
  mmBus = 0x12;                    // write 8bit value to MM port (G0-G7)

  // reading from 8bit port:
   mmBus.pinMode(INPUT_PULLUP);    
   uint8_t val = mmBus;          // read 8bit value from MM port (G0-G7)

(Might be good to rename mmBus to mmPort...)
 
Qt builds now. Will test tomorrow. Need to change build to release instead of debug

Good work and good luck KurtE! Looking forward to getting to use it.

As KurtE saw in Github email - @koromix will build release if the debug version of the edited code works.
 
Last edited:
@defragster and all - My update to the last post was not typed correctly - It should have said I needed to change the debug to release in order to get it to build correctly...

Here is a run of on my machine is the HiLow test... Should probably update to what you have now....

screenshot.jpg
So at least some of the basics are there. What I have not tried yet are to configure Arduino to upload using Tycommander and see if it works.
Nor have I configured my machine for example to support MTP + Serial for this device to see if that works in SublimeText.

Not sure how best to allow others to try these. I did mention up on the github issue the steps I took, which included a fresh install of the project, downloading a fresh copy of QT5 static library (from his Readme), I built using the Native 64 bit command prompt. Then go back to main readme and create the build\win64 directory, doing the cmake, opening up solution, try the build (Failed), then changed the build type from debug to release tried building and it worked...

Update: I told the TyCommander to integrate, and then I started Arduino again and rebuilt the hilow, and it was able to upload the program and start again.
Rest Button appear to Reset, bootloader button appears to set into bootload mode and then can program again...

update2: Sublimetext4 in this state is not being able to reset/program it... Need to make sure it works on other boards. Maybe a change I missed making
(Oops needed to update the main TSET to point to this version...)
 
Last edited:
Good morning all,
Was playing some more the camera code. I added what @luni pointed to read the bus - probably did it wrong though. I did add the framebuffer code to take a snap shot - have to go over it again. Did comment out a bit. But this time I added a ST7789 320x40 display to dump the framebuffer. So camera now has first light:
IMG-0340.png

But at least its displaying raw data from the frame buffer. Question - it dumps the data in Bayer form so not sure what I have to do get it converted to RGB - or do I have to do anything.

Anyway this is what i have so far.
 

Attachments

  • HM01B0.zip
    11 KB · Views: 43
Morning All
Think I need a short break from camera stuff - getting a headache - so close :)

A couple of things to remember when playing with the library - a lot of extra stuff but a few points:
1. Camera only supports QVGA and only Grayscale not color :(
2. The SHM01B0INIT register setup from sparkfun seems to not do anything except hang the TMM.
3. Colorbar and other test does work but seems to leave it in a crazy state - think have to reload the registers after testing which I didn;t do - have to work on that one.
4. Don't think I am doing the framebuffer in sensor_snapshot correctly
5. Might say well what's working = well all the functions seem to work just from my playing with the camera.

Spending a lot of time on the getting the snap shot working with the display - probably just use the python script as an image test as opposed to the display. Then can play with a few other functions and bounce it against the Sparkfun library and maybe copy a the auto exposure stuff over.
 
Morning @mjs513 and all:

Camera: As I mentioned elsewhere, I think, I may try with different camera (OV7670) as there is a lot more information publicly available, and I have DMA code that worked OK for it on T4.1 (and 4)... So might be a good starting point. Assuming it works, may then try converting from DMA to to FlexIO and see how well that works.

But first diversion back to diversion of... MTP, working on adding support for format of SD Cards like we have in the formatter...

Note right now I am playing with it on the Machine Learning ATP board...

SD cards on MicroMod: So far I have not found a carrier board that uses SDIO setup. The Teensy board and MM do have defines for SDIO signals but not used. Example Machine learning the pin usage to MM is shown in:
screenshot2.jpg

And if you look at the SD area of the schematic it shows SPI pins with CS I am pretty sure is Teensy pin 10...
screenshot.jpg

I went to look at this as I was curious if their SD card adapter had a card inserted pin connected or not... Does not look like it.

I then went and looked at the DataLogger schematic and it looked more promising at first as the SD section shows bubbles going into DATA2 and 3, but those bubbles don't connect to anything and again nothing in the SDIO section of the Micromod object is connected... ATP does not have an SD connector, although one could hook up their own... Have not checked others.
 
@KurtE
Morning again.

Funny you posted about the SD Card. Was just playing with it to save an image to the SD Card and discovered the same thing. It doesn't use SDIO - only checked the Machine learning board so far. It uses SPI with the default chip select as pin 10. So if you are going to use it have to specify SD.begin(10) otherwise it won't work :(

As for the camera looks like I have to figure out how to do grayscale to RGB since everything we have uses RGB. Still trying to sort out whether the data out for grayscale are uint16's or just uint8's? Need a break. Going to attach my latest sketch and updates to the lib.
 

Attachments

  • HM01B0.zip
    15.5 KB · Views: 45
Back
Top