Shop OBEX P1 Docs P2 Docs Learn Events
Communication btw Propellers and mic-to-head object — Parallax Forums

Communication btw Propellers and mic-to-head object

Dear All,

I wanted to ask once more for help regarding a development project I am doing using the Propeller 1. I already posted two discussion in the past, but I have still a lot of unclear things to clarify due to my poor understanding of PASM (I am new to the job).

Let me start by giving you an understanding of my project:
For my university group, I am tasked to develop a way to have audio communication between two Propeller 1 Activity Boards. At the moment, I want to input, by microphone, voice into a Propeller 1 and have it come out through headphones connected to another Propeller 1, with a direct physical connection between them.

Here is how I am attacking the problem:
I firstly familiarized myself with the microphone to headphone object, with a few modifications (with help form the forum) and choosing the right mic, it works well and I am satisfied by the audio quality.

I then checked and fixed a PCM (13-bits) to A-law (8-bits) encoding script that was previously developed by my research group: the signal from the ADC part of the microphone to headphone object , is taken, encoded, decoded and output to the headphone after DAC. The conversion works well (I will push it in the GitHub once I have properly understood it).

At this point I would like to split the microphone to headphone object so that I talk into Propeller Activity Board (A) and output the audio from Propeller Activity Board (B). My idea to do this (and understand PASM on the way) is the following:

1) Modify the microphone to headphone object so that the output of the AD conversion (13-bit PCM put into a cog long register) is saved in the hub, picked later form the hub and used for the DA conversion.

2) Split the ADC and DAC PASM code so that two cogs run it in parallel, with the DAC picking the 13-bit PCM signal of the ADC form a shared hub register.

3) Check/modify already available SPI drivers to connect two Propeller Activity Boards together.

4) Make it so that the two Propeller Activity Boards (A) and (B), now connected through one SPI connection, have both two cogs running with a reciprocal continuous ADC and DAC: (A) does ADC (13-bit PCM) sends it in 32 bit package to the HUB of (B), the DAC cog of propeller (B) takes the 32-bit signal from the hub register and does DAC conversion on it, and vice versa.

I am already stuck at 1), as you can read it in the object I attached, I save the signal from the ADC to the hub and get it again for DAC two lines later, but I get a crazily distorted output from the headphones. I know that this is because of timing and sampling: I should probably sample the 13-bit PCM from the mic every "x" cycles, write it in the hub and use it "x" time for the DA conversion, but I have no idea how this works and how to start with the problem and can't really find any "clear" way to understand PASM fastly and figure it out.

Another alternative that I am considering for the project is to pair the propellers with a DAC (MCP3204) and DAC (MCP4921), this would make the implementation go down to establishing the SPI communications between the components, but I would like to develop this tool only using the Propeller 1.

Any help is greatly appreciated, I hope to understand PASM soon and be able to also participate and help in the discussion in a more meaningful way,
Domenico

Comments

  • Just an update: worked out point 1), now stuck at point 2), attached the working code and not working code of the two

  • AribaAriba Posts: 2,682

    If you write code for 2 PASM cogs in the same Spin file, you need to separate not only the code but also the register variables.
    adc_variables needs to go behind the adc code, and dac_registers behind the dac code.
    And most important: the code for the second cog needs its own ORG , so that the compiler compiles it beginning at cog-address 0 also for the second cog.
    Best is to make two DAT sections, one for each cog. I also found that register-variables defined with RES are really dangerous in such a situation, better declare the registers with LONG 0 instead:

    DAT
            org
    entry1  <code1>
    
    var1a   long  0
    var1b   long  0
    
    
    DAT
            org
    entry2  <code2>
    
    var2a   long  0
    var2b   long  0
    

    Andy

  • Thank you Andy, as always you were right, now it works as intended!
    Attached the object, just in case. It seems it is only a matter of properly connecting to propellers together now and change the hub addresses accordingly. Any suggestions on which interface is best to connect two Propellers serially? I have seen there is already a well documented PropBus on GitHub, should I try this?

    Thank you again,
    Domenico

Sign In or Register to comment.