frame

Can't open Hexiwear SD card slot

Hello everyone!

I was trying to use the examples available with Zerynth in order to open and save files (FileSystem example) or just data (SpiSD) to a SD card using the Hexiwear SD slot. However i can't open the SD card, read or write files or save data.  In the pinmap of Hexiwear it is written that this SD slot uses SPI3, however in the Hexiwear port.def file it is defined as SPI1 protocol. I also saw in this file that the CS pin is the D25 but it is not shown on the pinmap available in the Zerynth pinmap.

 I just tried to use both SPI but i just had the same result, this is, the prints of data are not shown but i also don't receive any error in the console.

Code tried:

//my_sd = spisd.SpiSD(SPI3, D25)
another try:
//my_sd = spisd.SpiSD(SPI1, D25)

In file stream example:
fatfs.mount('0:/file/', {"drv": SPI1, "cs": D25, "clock": 1000000} )
//
fatfs.mount('0:/file/', {"drv": SPI3, "cs": D25, "clock": 1000000} )

I've also tried to mount the file system to the flash external memory but it didn't work as well:
fatfs.mount('0:/file/', {"drv": SPI1, "cs": D56, "clock": 1000000} )


I would like to know what i have to do and how i can change it in order to save files to the hexiwear SD slot card or to the external flash memory.

In my last discussion i have made a question and i have not obtained any answer untill now. I would like to know if anyone of you had this problem with the interrupts and what i should do in order to fix the problem. Link: https://community.zerynth.com/discussion/525/cant-change-sample-rate-of-maxim-30101-module#latest

Thanks in advance,

Comments

  • Hello @"José Alves" 

    regarding the SPI issue, I suspect a bug in the VM pin definitions. As soon as it is replicated, we will release a fix in the next update.

    For the other issue you experienced with the heart rate sensor, @"Matteo Cipriani", the maintainer of that library, will come back to you asap.
    Giacomo Baldi
    Zerynth Head of Software Development
  • Thank you for the quick answer!

    I will wait for this fix, Thank you!

    I still need the help for the heart rate sensor question so i would be really grateful if he can help me!

    Thank you!
  • I have good news.

    I have just plugged in the Docking station in other pc with Zerynth, then i restored the firmware of the sensors and when connecting back to the pc that i was using the interrupts start to work again.

    I just thank you for all you help, and I'm looking forward to have good news about this bug fix in the next update. I'm waiting for it.

    Thanks you all!

    José Alves
  • Hi Josè,

    regarding the SPI and microSD card issue, I succeed to replicate the error and I'm investigating to solve the bug.
    The problem seems to be about ignored SPI configuration for intercating with the SD card.

    The numbering of SPI peripherals (and every other pin or peripherals) in Zerynth Pinmap are reference labels for remapping and easing usage of microcontroller pins. The SPI1 label in port.def is a comment ("SPI1 ON CHIP") referred to hardware SPI numbering (see NXP Kinetic k64 datasheet).

    So SPI3 is correct for interacting with the microSD card slot and D25 is the chip select to enable it (label on pinmap will be draw in next release); SPI1 with D56 as CS is correct for interacting with external SPI flash.

    The possibility to handle files over external SPI flash is not available for now; this feature will be implemented very soon.

    Stay tuned for updates and sorry for the late answer :)
    Matteo Cipriani
    Zerynth Support Team
  • Hello!

    Thank you for the help.
    Looking forward to read some news from this update.

    I'm sorry again, but the interrupt pin stopped working once more. I tried what i did before but now it didn't work.
    However i tried another tool to program the Hexiwear and specifically the Maxim 30101 sensor and with it the interrupt has worked. I don't know but it seems that the problem/bug is of the Zerynth libraries, specifically, the VM, while when i changed the PC it started working and then after some time working it suddenly stopped again.

    Thank you for the help.
    Best Regards,
    José Alves
  • Hi Josè,

    r2.0.10 is out!!! In this release, we update the max30101 library improving enable, read and disable interrupt features.

    Here you can find the new documentation and in the following folder, you can find new source file. 

    Linux and MacOS: "~/.zerynth2/dist/r2.0.10/libs/official/maxim/max30101"
    Windows: "C:/Users/your_user/zerynth2/r2.0.10/libs/official/maxim/max30101"

    Let me know if this can fix the issue.
    Feel free to write me if you need further help :)

    Matteo Cipriani
    Zerynth Support Team
  • Hello Matteo!!!
    Thank you for the effort on this new update and for all the improvements.

    However, i still can't get read the interrupts. For what i saw in the docs and the maxim30101 file you only have add the options of enable more than one interrupt (input list) and read which one is triggered, Am i right?

    I just tried a list of some interrupts but it still not working (neither i have response from the read_triggered_interrupt() function), for the "temp" or/and "data" interrupts which are from my interest. I think that the problem is related with the communication Zerynth - MCU (probably the VM, i don't know exactly), since when i changed the first time of computer it started working again but now it does not work anymore.

    Regarding the problem with  the SD card and the flash. Now the example Flash example available works, however the Filesystem example, in order to create a file in the SD card slot of the Hexiwear dock station, still not working.
     I just checked that the problem occurs in this line of code:
    ww = os.open('0:zerynth.txt', 'w')
    so the fatfs.mount of the sd card is working well.

    Also from what i  saw in the os.py file there's no the "w" option on the function open(), so i don't know if it can be an input of this function.

    I hope i'm helping on the improvement of the Zerynth and the Hexiwear/ Maxim 30101 libraries and that you can check what's happening and hopefully help me with my work!

    Thank you,
    Best Regards!

  • Hi Josè,

    About the SDcard and filesystem issues, thanks for your tips; we are working on it.

    Regarding the max30101, you can try the following script:

    import streams
    from maxim.max30101 import max30101
    
    streams.serial()
    
    cnt_temp = 0
    cnt_data = 0
    
    def fnc(obj):
        try:
            interrupts = obj.read_triggered_interrupt()
            print(interrupts)
            if "temp" in interrupts:
                cnt_temp += 1
                print("---------------------------")            
                print("Temp:", obj.get_temperature(), "count_temp:", cnt_temp)
                print("---------------------------")
            if "data" in interrupts:
                dd = obj.read_raw_samples(6)
                cnt_data += 1
                print("Data:",[e for e in dd], "count_data:", cnt_data)
        except Exception as e:
            print(e)
    
    # create an instance of the MAX30101 class
    try:
        pinPowerOn = D70
        pinMode(pinPowerOn,OUTPUT)
        digitalWrite(pinPowerOn,HIGH)
        
        # init sensor
        max = max30101.MAX30101(I2C0)
        print("start...")
        max.start()
        # init interrupt pin
        pinMode(D47,INPUT_PULLUP)
        onPinFall(D47,fnc,max)
        print("enable interrupts")
        max.enable_temperature()
        print("init...")
        max.init()
        max.enable_interrupt(["temp","data"])
        print("Ready!")
        print("---------------------------")
    except Exception as e:
        print(e)
    
    flag = True
    
    count = 0
    while True:
        try:
            sleep(500)
            if not flag:
                flag = True
                print("Enable interrupts")
                max.enable_interrupt(["temp","data"])
                print("start temperature measurement")
                max.enable_temperature()
            else:
                print("Disable interrupts")
                flag = False
                max.disable_interrupts()
                cnt_temp = 0
                cnt_data = 0
                sleep(1000)
        except Exception as e:
            print(e)
            sleep(5000)
    As reported in our "max30101" documentation, the argument of enable_interrupt() method must be a list (even if you want to enable one single interrupt).

    Furthermore, to get the temperature data, every time you have to call the enable_temperature() method that allows the max30101 to start the temperature measurement.

    Lastly, as reported in max30101 datasheet (page 16), every time a "data" interrupt is signaled you have to read the complete sample which is formed by (3 bytes) * (num_of_led_activated) - for example in "spo2" mode, there are only 2 leds activated so you have to read 6 bytes otherwise the write/read pointer increments its value slower than the filling index of the FIFO itself and, when the FIFO will be full, "data" interrupt never triggers again.

    In this script, you can test the behavior of the max30101 in "spo2" mode: in every cycle, interrupts are enabled for 500 ms and disabled for 1500 ms.
    When the interrupts are enabled, two counters are incremented every time is triggered a "data" or a "temp" interrupt.
    At the end of every cycle, you should obtain 1 temperature interrupt and 25 data_ready interrupts (in "spo2" mode, indeed, the default sampling frequency is 50 Hz).

    Let me know if this can help you and stay tuned for new updates :)
    Matteo Cipriani
    Zerynth Support Team
  • Hi Matteo!!!

    Thanks for your help.
    In fact, i'm does not need the temperature measurements but only the "data" measurements. I understood the functions of the library and the new updates that you have done, thanks for the explanation. However when i try to use your example in the console i don't obtain any data neither temperature as you can see by the screenshoot in attachment.

    I tried to do the polling, this is,in the main loop i just tried this code:
    While(True):
       val = max.read_raw_samples(6)
        hr = (val[3]<<16 | val[4] << 8 | val[5])
        print(hr)
        sleep(20)

    And i have obtained the data from the sensor in SpO2 mode (and the data is different from iteration to iteration which means that the FIFO is getting cleared). Thus i really think that the problem occurs with the InterruptPin of the sensor and its communication with Zerynth or the MCU.
    When i got in touch with the Hexiwear support team i could solve the problem but then sometime after i started again to get no answer from the Interrupt pin of the sensor through Zerynth.

    I hope you can help me to solve this problem,
    Sorry for the inconvenience!
    Thanks in advance!!
    Best regards,



    console.png 30.5K
  • Hi Josè,

    as described on page 13 of max30101 datasheet, there is an interrupt (PWR_RDY) that cannot be disabled and that triggers every time the max30101 is powered up.

    This event keeps the interrupt pin low until the reading of the interrupt status register; if you don't clean it (reading the interrupt status register) the pin remains low and onPinFall method cannot triggers.

    add this instruction on line 43 of the script and let me know!!!

    max.read_triggered_interrupt()
    Matteo Cipriani
    Zerynth Support Team
  • Hi!!!
    I don't know how to thank you, it was just it that was missing. I'm sorry but i'm missed the part that said that this triggered interrupt always that the device was turned on.

    Now it is working!! Thank you very much!!
    Looking forward to the updates on the SD cards and filesystem in order to save the data!

    Thank you one more time,
    Best Regards!!!
Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.