Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ИИС рег.параметров ГМП.doc
Скачиваний:
1
Добавлен:
01.07.2025
Размер:
14 Мб
Скачать
☆

3.3 Синтез по для персонального компьютера (пк)

Последовательность операций, которые описаны выше, можно реализовать как аппаратно, так и программно (рисунок 3.6.)

Рисунок 3.6 - Алгоритм управления магниторезистивным модулем

Также в дипломной работе был предложен алгоритм ПО ПЭВМ.

Согласно предложенным алгоритмам работы, управления и вычисления произведем синтез программного обеспечения (синтезируем программный код) на языке высокого уровня Си, реализующего алгоритм, приведенный на рисунке 3.6 и на языке Си++.

Универсальность, однозначность и гибкость оговоренного лингвистического обеспечения позволяет максимально точно и корректно программно решить преследуемые задачи.

Запишем фрагмент программного кода ниже.

#include<io.h>

#include<ioml 6.h>

#include<stdio.h>

#mclude<interrupt.h>

#include<delay.h>

#include<math.h>

#defme DP 0b 10000000

#definezero O b l l l l l l l l

#defineone Obi 1110011

fine two 0b 10001001

#define three OblOlOOOOl

#defme four 0b 10010010

#defme five OblOlOOlOO

#defmesix OblOOOOlOO

#defme seven Obi 1110001

#defme eight Ob 10000000

#defmenine OblOlOOOOl

#definefull ObOOOOOOOO

#define norma 50

void USART_init()

{

UCSRA = ( 1 ≪ 1 ) ;

UCSRB |= (1 ≪ 7) | (1 ≪ 4) | (1 ≪ 3);

UCSRC|=(1≪7);

U C S R C | = ( 1 ≪ 1 ) | ( 1 ≪ 2 ) ;

UCSRC -= 128;

UBRRH = 0;

UBRRL = 51;

}

void {

TCCR0=0b0O0O0011;

}

void ADC_init()

{

ADCSRA=(1≪7);

}

void PORTS_init()

{

DDRB=0xFF;

DDRC=0xFF;

}

void SET()

{

PORTC=0b00000010;

_delay_ms(30);

PORTC=0b00000000;

_delay_ms(30);

PORTC=0b00000001;

_delay_ms(30);

}

void RESET()// RESET-импульс

{

PORTC=0b00000001;

_delay_ms(30);

PORTC=0b00000000;

_delay_ms(30);

PORTC=0b00000010;

_delay_ms(30);

}

double Z;

unsigned int i;

void TESTindicatorQ

{

for(i=0; i<5;i++)

(PORTB=full;

delay_ms(1000);

PORTB=zero;

_delay_ms(1000);}

}

unsigned char temp,H,L;

double

ADC0_data,ADCl_data,ADC2_data,halfSET,fullHIPset,halfRESET,fullHIPreset,

U,B,U_ADC;

int main (void)

{

PORTS_init();

USART_init();

TC0_init();

ADC_init();

TEST indicator()

A:

SET();

ADMUX=0bOO0;

ADCSRA=0b 11000000;

_delay_ms(20);

ADCO_data=ADCL+(ADCH*OxlOO);

ADMUX=0b001;

ADCSRA=Obl 1000000;

_delay_ms(20);

ADC l_data=ADCL+(ADCH*Oxl 00);

ADMUX-ObOlO;

ADCSRA-Obl 1000000;

_delay_ms(20);

ADC2_data=ADCL+(ADCH*0xl00);

fullHIPset=sqrt(square(ADC0_data)+square(ADCl_data)+square(ADC2_data));

RESET();

ADMUX=ObOOO;

ADCSRA=Obl 1000000;

_delay_ms(20);

ADCO_data=ADCL+(ADCH*Oxl 00);

ADMUX=0b001;

ADCSRA=Obl 1000000;

_delay_ms(20);

ADCl_data=ADCL+(ADCH*OxlOO);

ADMUX=0b010;

ADCSRA=Obl 1000000; _delay_ms(20);

ADC2_data=ADCL+(ADCH*0xl00);

fullHIPreset=sqrt(square(ADC0_data)+square(ADCl_data)+square(ADC2_data));

U_ADC=(fiillHIPset-fullHIPreset)/2;

U_ADOU_ADC/4;

H=U_ADC/OxlOO;

L=U_ADC-(H*OxlOO);

UDR=L;

_delay_ms(20);

UDR=H;

_delay_ms(20);

goto A;

return 0;

}

#pragma once

namespace CPU {

using namespace System;

using namespace System: :ComponentModel;

using namespace System: Collections;

using namespace System::Windows::Forms;

using namespace System: :Data;

using namespace System: :Drawing;

int A;

public ref class Forml : public System::Windows::Forms::Form

{

public:

Forml (void)

{

InitializeComponentO;

//

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~Forml()

{

if (components)

{

delete components;

}

}

private: System:.-Windows::Forms::RadioButtonA radioButtonl;

protected:

private

private

private

private

private

private

private

private

private

private

System:: Windows: :Forms: :RadioButtonA radioButton2;

System:: Windows: :Forms::NumericUpDownA numericUpDownl;

System::Windows::Forms::LabelA label 1;

System::Windows::Forms::ButtonA buttonl;

System::Windows::Forms::GroupBoxA groupBox 1;

System::Windows: :Forms: :RadioButtonA radioButton5;

System::Windows: :Forms: :RadioButtonA radioButton4;

System::Windows::Forms: :RadioButtonA radioButton3;

System::Windows::Forms::RadioButtonA radioButton8;

System::Windows::Forms: :RadioButtonA radioButton7;

private: System: :Windows::Forms::LabelA label2;

private: System::Windows::Forms::LabelA label3;

private: System::Windows::Forms::LabelA label4;

private: System::Windows::Forms::LabelA label5;

private: System::Windows::Forms::LabelA labe!6;

private

private

private

private

private

private

private

private

private

private

System::Windows::Forms::LabelA label8;

System::Windows::Forms::LabelA label7;

System::Windows::Forms::LabelA label9;

System::Windows::Forms::LabelA label 10;

System::Windows::Forms::LabelA labell 1;

System::Windows::Forms: :LabelA label 12;

System: :IO: :Ports::SerialPortA serialPortl;

System::Windows: :Forms: :TimerA timer 1;

System::Windows::Forms::PanelA panel 1;

System::Windows::Forms::ButtonA button2;

private: System::Windows::Forms::RadioButtonA radioButton6;

double fs(double x)

{

return (Math::Floor(Math::Sin(x)));

}

private: System: :ComponentModel::IContainerA components;

private:

/// <summary>

/// Required designer variable.

/// </summary>

#pragma region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

void InitializeComponent(void)

{

this->components = (gcnew

System: :ComponentModel: :Container());

this->radioButtonl = (gcnew

System:: Windows ::Forms: :RadioButtonQ);

this->radioButton2 = (gcnew

System:: Windows: :Forms: :RadioButton());

this->numericUpDownl = (gcnew

System: :Windows::Forms: :NumericUpDown());

this->labell = (gcnew System::Windows:.'Forms::Label());