Internal DAC

For general Flowcode discussion that does not belong in the other sections.
Post Reply
hippalator
Posts: 2
http://meble-kuchenne.info.pl
Joined: Tue Jul 15, 2025 9:05 pm
Has thanked: 2 times

Internal DAC

Post by hippalator »

Hello
New to Flowcode and microcontrollers.
Have an electronics education (early 1990's) and electrical background from before microcontrollers were a thing.
Recently found Flowcode and like it over Vizuino.
Its pretty easy for a newby like myself to config a DAC using Vizuino but I'm not sold on using an arduino for a small project I have in mind.


I would like to use an internal DAC (learning with the B0011) but know nothing about config'ing a DAC in Flowcode.
Could anyone here point me to some Flowcode learning material on how to go about seting up an internal DAC?

Thank You

chipfryer27
Valued Contributor
Posts: 1621
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 358 times
Been thanked: 567 times

Re: Internal DAC

Post by chipfryer27 »

Hi

The WiKi is a good place to start https://www.flowcode.co.uk/wiki/index.p ... =Main_Page

If you then type DAC into the search bar (middle left) you will get a list of related items to choose from including Internal DAC. You can also get to the WiKi directly by right-clicking the component and choosing "Help".

The WiKi by nature is a work in progress and sometimes examples are still to be added.

This link has both Sawtooth and Sine wave examples https://www.flowcode.co.uk/wiki/index.p ... :_General)

Another good source of help is the Examples and Tutorials page, again accessed from the WiKi https://www.flowcode.co.uk/wiki/index.p ... _Tutorials

The YouTube channel can also be very helpful https://www.youtube.com/user/MatrixMultimediaLtd

Hope this helps.

chipfryer27
Valued Contributor
Posts: 1621
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 358 times
Been thanked: 567 times

Re: Internal DAC

Post by chipfryer27 »

Hi

Extremely simple example attached.

Counter loops 32 times and outputs value to DAC before starting again.

If you simulate you will see the "voltage" rise on the DAC component.

Regards
Attachments
ExampleDAC.fcfx
(9.73 KiB) Downloaded 8 times

hippalator
Posts: 2
Joined: Tue Jul 15, 2025 9:05 pm
Has thanked: 2 times

Re: Internal DAC

Post by hippalator »

chipfryer27 wrote:
Fri Jul 18, 2025 6:50 am
Hi

Extremely simple example attached.

Counter loops 32 times and outputs value to DAC before starting again.

If you simulate you will see the "voltage" rise on the DAC component.

Regards
Thanks for the help ChipFryer (love the name)
Question:
What sets the voltage increment for each loop cycle in the above example?
I can follow and understand the code but not seeing where the increment value is set.

My project is to build a stable (rail to rail) sine-wave generator.
MCU's fit the bill for stability.
Sine-wave generator chips (my era of the 90's) are no longer in production with the advent of MCU's.
So here I am way behind the MCU ball with virtually no experience in programming them.
In Vizuino you simply type the output frequency you desire in its respective block and BINGO out of the DAC comes the frequency.
Pretty simple.
The 328P MCU is a great chip, but its not a PIC and Vizuino does not program PIC's.

I've searched the web looking for examples of how to program a DAC (internal or otherwise) rail to rail sine-wave.
Any help is appreciated.

chipfryer27
Valued Contributor
Posts: 1621
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 358 times
Been thanked: 567 times

Re: Internal DAC

Post by chipfryer27 »

Hi

Without Flowcode I probably would have struggled with microcontrollers at least until Arduino and Raspberry Pi devices appeared. Flowcode without question makes it possible for those that don't think they are programmers to develop and deploy complex code. Using Flowcode a program developed for one target, say a PIC, can easily be ported to another device even outwith the family, for example an Arduino just with a few clicks, so any example you find in the WiKi or forum can usually work for almost any target.

In my simple example above, the target has an internal DAC with a 5-bit resolution, which is 32 steps (0-31). The program enables the DAC (tells it to start working) and loops incrementing a counter once every second using a variable "count". The value of "count" is used in the component macro DAC Output: SetOutput(Count) to tell the DAC what voltage to output. With 5-bit resolution giving 32 values including zero, each step would increment by 0.16129 volts for a 5v VDD. Note that in the component properties you can set the voltage reference to suit. Once the count reaches a predefined limit, the DAC is disabled (switched off) and then the whole process repeats.

Once the count reaches it's upper limit, if instead of repeating you modified to decrement the counter you would then have a chart that swept from 0v to Vdd and back down again. If this was then repeated you would achieve a very basic, simplistic sine output based on the delay.

As well as the Sine wave example I linked to in my previous post, have a look at the Digital Signal Processing (DSP) capabilities (Components > DSP), which includes a waveform generator. DSP is possibly not something a complete beginner may wish to jump straight in to, but if they did Flowcode is probably one of the easiest ways to do so. Flowcode has many examples and tutorials on DSP and if of interest have a look in the learning centre too https://www.matrixtsl.com/

Regards

Post Reply